Vjudge题目链接,水题,题目怎么说就怎么写。
1e4 就算是 n 2 n^2 n2也能过,何况根本到不了 n 2 n^2 n2
Sample Input
2
3
13
Sample Output
0 1 1 1 0 0 0 0 0 0
1 6 2 2 1 1 1 1 1 1
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
int cnt[10];
int main(){
int n;
cin>>n;
while(n--){
int x;
cin>>x;
memset(cnt, 0, sizeof(cnt));
for(int i = 1; i <= x; i++){
int tmp = i;
while(tmp > 0){
cnt[tmp%10]++;
tmp/=10;
}
}
for(int i = 0; i < 10; i++){
printf("%d", cnt[i]);
if(i != 9)printf(" ");
}
printf("\n");
}
return 0;
}