#include <iostream> #include <algorithm> #include <vector> using namespace std; #define ll long long #define pll pair<ll, ll> #define pb push_back const int s = 25; ll ans[s]; void f() { //input ll n, m = 1; cin >> n; for (ll i = m; i <= n; i++) { int x = i; while (x >= 10) { int y = 1; while (x) { y *= x % 10; x /= 10; } x = y; } ans[x]++; //cout << x << " "; } for (int i = 0; i <= 9; i++) cout << ans[i] << " "; for (int i = 0; i <= 9; i++) ans[i] = 0; cout << "\n"; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t; cin >> t; for (int i = 0; i < t; i++) f(); }
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 | #include <iostream> #include <algorithm> #include <vector> using namespace std; #define ll long long #define pll pair<ll, ll> #define pb push_back const int s = 25; ll ans[s]; void f() { //input ll n, m = 1; cin >> n; for (ll i = m; i <= n; i++) { int x = i; while (x >= 10) { int y = 1; while (x) { y *= x % 10; x /= 10; } x = y; } ans[x]++; //cout << x << " "; } for (int i = 0; i <= 9; i++) cout << ans[i] << " "; for (int i = 0; i <= 9; i++) ans[i] = 0; cout << "\n"; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t; cin >> t; for (int i = 0; i < t; i++) f(); } |