java class

jr_zlw / 2024-09-19 / 原文

cstdio

import java.util.Scanner;
class Read
{
    //i like C++ getchar() forever QwQ !!!
    //i don't know why java scanner do not have that QAQ !!!
    static Scanner sc;
    static String buff;
    static int bufP;
    Read()
    {
        sc=new Scanner(System.in);
        buff="";bufP=0;
    }
    static void Refresh()
    {
        buff=sc.nextLine();
        bufP=0;
    }
    public static char getchar()
    {
        if(bufP==buff.length())Refresh();
        if(buff.length()==0)return (char)(-1);
        else return buff.charAt(bufP++);
    }
    public static int read()
    {
        char ch=getchar();
        boolean flag=false;
        int res=0;
        while(ch<'0'||ch>'9')
        {
            flag^=(ch=='-');
            ch=getchar();
        }
        while(ch<='9'&&ch>='0')
        {
            res=res*10+(ch^48);
            if(bufP<buff.length())ch=getchar();
            else break;
        }
        return res;
    }
    public static char rd()
    {
        char ch=getchar();
        while(ch<'A'||ch>'Z')ch=getchar();
        return ch;
    }
}
public class Main
{
    public static void main(String[] args)
    {
        Read a=new Read();
        int n=a.read();
        int []cnt=new int[26];
        for(int i=0;i<n;++i)++cnt[a.rd()-'A'];
        for(int i=0;i<26;++i)
        {
            System.out.printf("%c: %d\n",(i+'A'),cnt[i]);
        }
    }
}