#include<bits/stdc++.h> using namespace std; #define ll long long #define pb push_back int DP[1000006]; ll T[1000000][10]; int W[1005]; int iloczyn(int a) { int odp=1; while(a>=1) { odp*=a%10; a/=10; } return odp; } int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t; cin >> t; ll n; for(int i = 1 ; i<=9;++i) {DP[i]=i; for(int j = 0; j<=9;++j) T[i][j]=T[i-1][j]; ++T[i][DP[i]];} for( int i = 10 ; i<=1000000 ; ++i) { DP[i]=DP[iloczyn(i)]; for(int j = 0; j<=9;++j) T[i][j]=T[i-1][j]; ++T[i][DP[i]]; }; for(int z = 1 ; z<=t ; ++z) cin >>W[z]; for(int z=1;z<=t;++z) { n=W[z]; for(int j = 0 ; j<=9 ; ++j) cout << T[n][j]<< " "; cout << "\n"; } return 0; }
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 | #include<bits/stdc++.h> using namespace std; #define ll long long #define pb push_back int DP[1000006]; ll T[1000000][10]; int W[1005]; int iloczyn(int a) { int odp=1; while(a>=1) { odp*=a%10; a/=10; } return odp; } int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t; cin >> t; ll n; for(int i = 1 ; i<=9;++i) {DP[i]=i; for(int j = 0; j<=9;++j) T[i][j]=T[i-1][j]; ++T[i][DP[i]];} for( int i = 10 ; i<=1000000 ; ++i) { DP[i]=DP[iloczyn(i)]; for(int j = 0; j<=9;++j) T[i][j]=T[i-1][j]; ++T[i][DP[i]]; }; for(int z = 1 ; z<=t ; ++z) cin >>W[z]; for(int z=1;z<=t;++z) { n=W[z]; for(int j = 0 ; j<=9 ; ++j) cout << T[n][j]<< " "; cout << "\n"; } return 0; } |