#include <iostream>
#include <stack>
using namespace std;
int main()
{
stack <int> stos;
int t,n,a;
cin>>t;
for (int i=0;i<t;i++)
{
cin>>n;
int tab[10]={0};
for(int b=0;b<n;b++)
{
a=b+1;
while(a>9)
{
while(a>0)
{
stos.push(a%10);
a=a/10;
}
a=1;
while(!stos.empty())
{
a=a*stos.top();
stos.pop();
}
}
tab[a]++;
}
for(int f=0;f<10;f++)
{
cout<<tab[f]<<" ";
}
cout<<endl;
}
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 <iostream> #include <stack> using namespace std; int main() { stack <int> stos; int t,n,a; cin>>t; for (int i=0;i<t;i++) { cin>>n; int tab[10]={0}; for(int b=0;b<n;b++) { a=b+1; while(a>9) { while(a>0) { stos.push(a%10); a=a/10; } a=1; while(!stos.empty()) { a=a*stos.top(); stos.pop(); } } tab[a]++; } for(int f=0;f<10;f++) { cout<<tab[f]<<" "; } cout<<endl; } return 0; } |
English