#include <bits/stdc++.h>
#define ll unsigned long long
using namespace std;
ll calc(ll x){
ll product = 1;
while(x > 0){
product *= x % 10;
x /= 10;
}
return product;
}
int main(){
ios_base::sync_with_stdio(0);
cout.tie(0); cin.tie(0);
vector<vector<ll>> ans(1'000'0001, vector<ll>(10, 0));
vector<ll> mdp(1'0000'001, 0);
for(ll i=1; i<=9; i++) mdp[i] = i;
for(ll i=1; i<=1'0000'000; i++){
ll product = calc(i);
ans[i] = ans[i-1];
ans[i][mdp[product]]++;
mdp[i] = mdp[product];
}
ll sets; cin>>sets;
while(sets--){
ll x; cin>>x;
for(auto e: ans[x]) cout<<e<<' ';
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 | #include <bits/stdc++.h> #define ll unsigned long long using namespace std; ll calc(ll x){ ll product = 1; while(x > 0){ product *= x % 10; x /= 10; } return product; } int main(){ ios_base::sync_with_stdio(0); cout.tie(0); cin.tie(0); vector<vector<ll>> ans(1'000'0001, vector<ll>(10, 0)); vector<ll> mdp(1'0000'001, 0); for(ll i=1; i<=9; i++) mdp[i] = i; for(ll i=1; i<=1'0000'000; i++){ ll product = calc(i); ans[i] = ans[i-1]; ans[i][mdp[product]]++; mdp[i] = mdp[product]; } ll sets; cin>>sets; while(sets--){ ll x; cin>>x; for(auto e: ans[x]) cout<<e<<' '; cout<<'\n'; } return 0; } |
English