You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
736 B
33 lines
736 B
#include <bits/stdc++.h>
|
|
|
|
using namespace std;
|
|
|
|
int main() {
|
|
//开二维数组
|
|
int arr[11][10005];
|
|
//初始化
|
|
memset(arr, 0, sizeof(arr));
|
|
|
|
for (int i = 1; i <= 10005; i++) {
|
|
int e = i;
|
|
while (e) {
|
|
arr[e % 10][i]++;
|
|
e = e / 10;
|
|
}
|
|
for (int j = 0; j < 10; j++)
|
|
//打表 适合问题:所求的结果在过程中需要重复并且打表数据量不大
|
|
arr[j][i] += arr[j][i - 1];
|
|
}
|
|
|
|
int T;
|
|
cin >> T;
|
|
while (T--) {
|
|
int n;
|
|
cin >> n;
|
|
//这个分两段输出挺霸气!
|
|
for (int i = 0; i < 9; i++)
|
|
cout << arr[i][n] << " ";
|
|
cout << arr[9][n] << endl;
|
|
}
|
|
return 0;
|
|
} |