#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define pb push_back
LL liczba(LL a)
{
if (a == 0) return 0;
LL res = 1;
while (a > 0)
{
res *= (a % 10);
a /= 10;
}
return res;
}
LL znajdz(LL x)
{
while (x >= 10)
x = liczba(x);
return x;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
int t;
cin >> t;
while (t--)
{
LL n;
cin >> n;
vector<LL> res(10, 0);
for (LL i = 1; i <= n; i++)
{
LL cyfraKoncowa = znajdz(i);
res[cyfraKoncowa]++;
}
for (int i = 0; i <= 9; i++)
cout << res[i] << " ";
cout << endl;
}
}
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 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | #include <bits/stdc++.h> using namespace std; typedef long long LL; #define pb push_back LL liczba(LL a) { if (a == 0) return 0; LL res = 1; while (a > 0) { res *= (a % 10); a /= 10; } return res; } LL znajdz(LL x) { while (x >= 10) x = liczba(x); return x; } int main() { ios::sync_with_stdio(false); cin.tie(0); int t; cin >> t; while (t--) { LL n; cin >> n; vector<LL> res(10, 0); for (LL i = 1; i <= n; i++) { LL cyfraKoncowa = znajdz(i); res[cyfraKoncowa]++; } for (int i = 0; i <= 9; i++) cout << res[i] << " "; cout << endl; } } |
English