#include <bits/stdc++.h> #include "dzilib.h" using namespace std; #define fwd(i, a, n) for (int i = (a); i < (n); i ++) #define rep(i, n) fwd(i, 0, n) #define all(X) begin(X), end(X) #define sz(X) ((int)X.size()) #define st first #define nd second #define pii pair<int, int> #define vi vector<int> #define ll long long #ifdef LOC auto &operator<<(auto &out, pair<auto, auto> a) { return out << "(" << a.st << ", " << a.nd << ")"; } auto &operator<<(auto &out, auto a) { out << "{"; for (auto b : a) out << b << ", "; return out << "}"; } void dump(auto... x) { ((cerr << x << ", "), ...) << '\n'; } #define debug(x...) cerr << __LINE__ << ": [" #x "]: ", dump(x) #else #define debug(...) 0 #endif const int K = 100; const int M = 17; int32_t main() { //ios_base::sync_with_stdio(0), cin.tie(0); int t = GetT(); int n = GetN(); vector<int> div(n + K, 0); vector<int> divCnt(n+K, 0); divCnt[1] = 1; div[1] = 1; for(int i = 2; i * i < n + K; i++){ if(div[i] == 0){ div[i] = i; for(int k = i * i; k < n + K; k += i){ if(div[k] == 0)div[k] = i; } } } for(int i =0; i < n + K; i++)if(div[i] == 0)div[i] = i; /*for(int i = 0; i < n +K; i++){ cerr<<i<<" "<<div[i]<<"\n"; }*/ for(int i = 2; i < n + K; i++){ int p = div[i]; int x = 0; int v = i; while(div[v] == p){ x++; v /= p; } divCnt[i] = divCnt[v] * (x+1); //debug(i); } /*for(int i = 0; i < n +K; i++){ cerr<<i<<" "<<divCnt[i]<<"\n"; }*/ /*vector<array<int, M>> xd(n); for(int i = 1; i <= n; i++){ for(int k = 0; k < M; k++){ xd[i-1][k] = divCnt[i + k]; } } sort(all(xd)); for(int i = 1; i < sz(xd); i++){ if(xd[i] == xd[i-1]){ cout<<"ajaja\n"; debug(xd[i]); } }*/ array<int, M> tab; map<array<int, M>, int> ans; for(int i= 1; i <= n; i++){ for(int k = 0; k < M; k++){ tab[k] = divCnt[i + k]; } assert(ans[tab] == 0); ans[tab] = i; } rep(i, t){ rep(j, M){ tab[j] = Ask(j); } Answer(ans[tab]); } 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 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 | #include <bits/stdc++.h> #include "dzilib.h" using namespace std; #define fwd(i, a, n) for (int i = (a); i < (n); i ++) #define rep(i, n) fwd(i, 0, n) #define all(X) begin(X), end(X) #define sz(X) ((int)X.size()) #define st first #define nd second #define pii pair<int, int> #define vi vector<int> #define ll long long #ifdef LOC auto &operator<<(auto &out, pair<auto, auto> a) { return out << "(" << a.st << ", " << a.nd << ")"; } auto &operator<<(auto &out, auto a) { out << "{"; for (auto b : a) out << b << ", "; return out << "}"; } void dump(auto... x) { ((cerr << x << ", "), ...) << '\n'; } #define debug(x...) cerr << __LINE__ << ": [" #x "]: ", dump(x) #else #define debug(...) 0 #endif const int K = 100; const int M = 17; int32_t main() { //ios_base::sync_with_stdio(0), cin.tie(0); int t = GetT(); int n = GetN(); vector<int> div(n + K, 0); vector<int> divCnt(n+K, 0); divCnt[1] = 1; div[1] = 1; for(int i = 2; i * i < n + K; i++){ if(div[i] == 0){ div[i] = i; for(int k = i * i; k < n + K; k += i){ if(div[k] == 0)div[k] = i; } } } for(int i =0; i < n + K; i++)if(div[i] == 0)div[i] = i; /*for(int i = 0; i < n +K; i++){ cerr<<i<<" "<<div[i]<<"\n"; }*/ for(int i = 2; i < n + K; i++){ int p = div[i]; int x = 0; int v = i; while(div[v] == p){ x++; v /= p; } divCnt[i] = divCnt[v] * (x+1); //debug(i); } /*for(int i = 0; i < n +K; i++){ cerr<<i<<" "<<divCnt[i]<<"\n"; }*/ /*vector<array<int, M>> xd(n); for(int i = 1; i <= n; i++){ for(int k = 0; k < M; k++){ xd[i-1][k] = divCnt[i + k]; } } sort(all(xd)); for(int i = 1; i < sz(xd); i++){ if(xd[i] == xd[i-1]){ cout<<"ajaja\n"; debug(xd[i]); } }*/ array<int, M> tab; map<array<int, M>, int> ans; for(int i= 1; i <= n; i++){ for(int k = 0; k < M; k++){ tab[k] = divCnt[i + k]; } assert(ans[tab] == 0); ans[tab] = i; } rep(i, t){ rep(j, M){ tab[j] = Ask(j); } Answer(ans[tab]); } return 0; } |