问题类型:字符串,计数。
03pie’s solution for [UVA-1225]:
#include<cstdio>
#include<iostream>
#include<sstream>
#include<cstdlib>
#include<cmath>
#include<cctype>
#include<string>
#include<cstring>
#include<algorithm>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<ctime>
#include<vector>
#include<fstream>
#include<list>
using namespace std;#define ms(s) memset(s,0,sizeof(s))typedef unsigned long long ULL;
typedef long long LL;const double PI = 3.141592653589;
const int INF = 0x3fffffff;int main(){
// freopen("F://inp.txt","r",stdin);int T;scanf("%d",&T);while(T--){int n;scanf("%d",&n);int nubl[10];memset(nubl,0,sizeof(nubl));for(int d=1;d<=n;d++){int tmp=d,dit;
// printf("%d",tmp);while(tmp){ dit=tmp%10;nubl[dit]++;tmp=tmp/10;} if(d%10==0&&!d){nubl[tmp]++;} } for(int i=0;i<10;i++){if(i==0) printf("%d",nubl[i]);else printf(" %d",nubl[i]);}printf("\n");}return 0;
}