#include <bits/stdc++.h>
#include <random>
using namespace std;
int tabliczka[10][10] = {
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 },
{ 0, 2, 4, 6, 8, 0, 2, 4, 6, 8 },
{ 0, 3, 6, 9, 2, 5, 8, 2, 8, 4 },
{ 0, 4, 8, 2, 6, 0, 8, 6, 6, 8 },
{ 0, 5, 0, 5, 0, 0, 0, 5, 0, 0 },
{ 0, 6, 2, 8, 8, 0, 8, 8, 6, 0 },
{ 0, 7, 4, 2, 6, 5, 8, 8, 0, 8 },
{ 0, 8, 6, 8, 6, 0, 6, 0, 8, 4 },
{ 0, 9, 8, 4, 8, 0, 0, 8, 4, 8 }
};
struct Wymnazarka {
Wymnazarka* wymnazarki[10] = { nullptr };
int policz(long long liczba) {
if(liczba < 10) return liczba;
int index = liczba % 10;
if (index == 0) return 0;
if (wymnazarki[index] == nullptr) {
wymnazarki[index] = new Wymnazarka;
}
return tabliczka[index][wymnazarki[index]->policz(liczba/10)];
}
};
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
//istringstream input("5\n10 56 57 123 1");
//cin.rdbuf(input.rdbuf());
int t = 1;
cin >> t;
int CHUNK = 10000000;
vector<vector<long long>> wymnozone(CHUNK+1, {0,0,0,0,0,0,0,0,0,0});
Wymnazarka* wymnazarka = new Wymnazarka;
for(int i=1; i<CHUNK+1; i++) {
int d = wymnazarka->policz(i);
wymnozone[i][d] = 1;
for(int j=0; j<10; j++) wymnozone[i][j] += wymnozone[i-1][j];
}
for(int i=0; i<t; i++) {
long long l_zabaw;
cin >> l_zabaw;
long long M = l_zabaw / CHUNK;
long long L = l_zabaw % CHUNK;
long long syfry[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0 ,0};
for(int j=0; j<10; j++) syfry[j] = wymnozone[CHUNK][j] * M + wymnozone[L][j];
for(auto syfra:syfry) cout << syfra << ' ';
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 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | #include <bits/stdc++.h> #include <random> using namespace std; int tabliczka[10][10] = { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }, { 0, 2, 4, 6, 8, 0, 2, 4, 6, 8 }, { 0, 3, 6, 9, 2, 5, 8, 2, 8, 4 }, { 0, 4, 8, 2, 6, 0, 8, 6, 6, 8 }, { 0, 5, 0, 5, 0, 0, 0, 5, 0, 0 }, { 0, 6, 2, 8, 8, 0, 8, 8, 6, 0 }, { 0, 7, 4, 2, 6, 5, 8, 8, 0, 8 }, { 0, 8, 6, 8, 6, 0, 6, 0, 8, 4 }, { 0, 9, 8, 4, 8, 0, 0, 8, 4, 8 } }; struct Wymnazarka { Wymnazarka* wymnazarki[10] = { nullptr }; int policz(long long liczba) { if(liczba < 10) return liczba; int index = liczba % 10; if (index == 0) return 0; if (wymnazarki[index] == nullptr) { wymnazarki[index] = new Wymnazarka; } return tabliczka[index][wymnazarki[index]->policz(liczba/10)]; } }; int main() { ios_base::sync_with_stdio(0); cin.tie(0); //istringstream input("5\n10 56 57 123 1"); //cin.rdbuf(input.rdbuf()); int t = 1; cin >> t; int CHUNK = 10000000; vector<vector<long long>> wymnozone(CHUNK+1, {0,0,0,0,0,0,0,0,0,0}); Wymnazarka* wymnazarka = new Wymnazarka; for(int i=1; i<CHUNK+1; i++) { int d = wymnazarka->policz(i); wymnozone[i][d] = 1; for(int j=0; j<10; j++) wymnozone[i][j] += wymnozone[i-1][j]; } for(int i=0; i<t; i++) { long long l_zabaw; cin >> l_zabaw; long long M = l_zabaw / CHUNK; long long L = l_zabaw % CHUNK; long long syfry[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0 ,0}; for(int j=0; j<10; j++) syfry[j] = wymnozone[CHUNK][j] * M + wymnozone[L][j]; for(auto syfra:syfry) cout << syfra << ' '; cout << '\n'; } return 0; } |
English