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
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

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

vector<int> policzWyniki(long long n) {
    vector<int> wyniki(10, 0);
    for (long long i = 1; i <= n; ++i) {
        int wynik = mnozenieCyfr(i);
        wyniki[wynik]++;
    }
    return wyniki;
}

int main() {
    int t;
    cin >> t;
    vector<long long> dni(t);
    for (int i = 0; i < t; ++i) {
        cin >> dni[i];
    }

    for (long long n : dni) {
        vector<int> wyniki = policzWyniki(n);
        for (int i = 0; i < 10; ++i) {
            cout << wyniki[i] << " ";
        }
        cout << endl;
    }

    return 0;
}