l1-003. Single-digit statistical time limit of MS memory limit 65536 KB code length limit 8000 B procedure StandardAuthor Chen
Given a k-bit integer n = dk-1*10k-1 + ... + d1*101 + d0 (0<=di<=9, i=0,..., k-1, dk-1>0), write the program to count the number of occurrences of each of the different digit digits. For example: given n = 100311, there are 2 0, 3 1, and one 3.
Input format:
Each input contains 1 test cases, a positive integer n of no more than 1000 bits.
Output format:
For each of the different single digit numbers in n, output the digit D and the number of occurrences of M in N in a row in d:m format. Required to be output in ascending order of D.
Input Sample:
100311
Sample output:
0:21:33:1
1#include <bits/stdc++.h>2 using namespacestd;3 intMain ()4 {5 inta[ One]= {0};6 strings;7Cin>>s;8 intT;9 for(intI=0; I<s.size (); i++)Ten { One if(s[i]!='0') A { -t=i; - Break; the } - } - for(inti=t; I<s.size (); i++) - { + intr=s[i]-'0'; -a[r]++; + } A for(intI=0; i<=9; i++) at { - if(A[i]) -printf"%d:%d\n", I,a[i]); - } - return 0; -}
l1-003. Single digit statistics