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
#include <bits/stdc++.h>
using namespace std;

vector<pair<long long,int>> v;

int oblicz(long long x){
    long long a = x;
    while(a>=10){
        x=a; a=1;
        while(x>0){
            a *= x%10;
            x/=10;
        }
    }
    return a;
}

int result[100005][10];

int main(){
    ios_base::sync_with_stdio(0);
    int t; cin >> t;
    for(int i=0;i<t;i++){
        int a; cin >> a;
        v.push_back({a,i});
    }
    sort(v.begin(),v.end());

    for(int i=0;i<t;i++){
        long long n = v[i].first;
        int a[10] = {0};
        if(i>0){
            for(int j=0;j<10;j++){
                a[j] = result[v[i-1].second][j];
            }
        }
        int before = 0;
        if(i>0) before = v[i-1].first;
        for(int j=before+1;j<=n;j++){
            a[oblicz(j)]++;
        }
        for(int j=0;j<10;j++){
            result[v[i].second][j] = a[j];
        }
    }
    for(int i=0;i<t;i++){
        for(int j=0;j<10;j++)
            cout << result[i][j] << " ";
        cout << '\n';
    }
}