#include <bits/stdc++.h> using namespace std; int zamien(int a) { int res = 1; while(a) { res*=a%10; a/=10; } return res; } const int N = 1010; const int A = 10; int res[N][A]; int act[A]; int main() { int t; cin>>t; vector<pair<int,int>> V(t); for(int i = 0 ;i < t; i ++) { cin>>V[i].first; V[i].second=i; } sort(V.begin(),V.end()); int j = 0; for(int i = 1; i <= V[t-1].first; i ++) { int tmp = i; while(tmp>=10) tmp = zamien(tmp); act[tmp]++; while(j < t && V[j].first == i) { for(int z = 0; z < A; z ++) res[V[j].second][z] = act[z]; j++; } } for(int i = 0 ;i < t; i ++) { for(int j = 0 ;j < A; j ++) cout<<res[i][j]<<' '; cout<<'\n'; } }
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; int zamien(int a) { int res = 1; while(a) { res*=a%10; a/=10; } return res; } const int N = 1010; const int A = 10; int res[N][A]; int act[A]; int main() { int t; cin>>t; vector<pair<int,int>> V(t); for(int i = 0 ;i < t; i ++) { cin>>V[i].first; V[i].second=i; } sort(V.begin(),V.end()); int j = 0; for(int i = 1; i <= V[t-1].first; i ++) { int tmp = i; while(tmp>=10) tmp = zamien(tmp); act[tmp]++; while(j < t && V[j].first == i) { for(int z = 0; z < A; z ++) res[V[j].second][z] = act[z]; j++; } } for(int i = 0 ;i < t; i ++) { for(int j = 0 ;j < A; j ++) cout<<res[i][j]<<' '; cout<<'\n'; } } |