fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. long res[10];
  5.  
  6. void d(int x) {
  7. while (x != 0) {
  8. res[x % 10]++;
  9. x /= 10;
  10. }
  11. return;
  12. }
  13.  
  14. int main() {
  15. long long n;
  16. cin>> n;
  17. for (int i = 1; i <= n; i++)
  18. d(i);
  19. for (int i = 0; i < 10; i++)
  20. cout<< i<< " "<< res[i]<< endl;
  21. return 0;
  22. }
  23.  
Success #stdin #stdout 0.01s 5284KB
stdin
123456
stdout
0 58985
1 93553
2 63553
3 59553
4 59053
5 58993
6 58986
7 58985
8 58985
9 58985