題目:
https://onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=3666
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
| #include <bits/stdc++.h> using namespace std; int main(){ ios::sync_with_stdio(0);cin.tie(0); int n; int kase; cin >> kase; while(kase--){ string result = ""; cin >> n; for(int i=1; i<=n; ++i){ result += to_string(i); } map<char, int> mp; for(char i = '0'; i<='9'; ++i) mp[i] = 0;
for(char c : result) mp[c]++;
bool first = true; for(auto it = mp.begin(); it != mp.end(); ++it){ if(!first) cout << ' '; first = false; cout << it->second; } cout << '\n'; } return 0; }
|