//#define _CRT_SECURE_NO_WARNINGS #include <iostream> #include <vector> #include <set> #include <fstream> #include "dzilib.h" #define int long long using namespace std; const int M = 1000005; int sit[M], dzi[M]; int32_t main() { //cin.tie(0); //cout.tie(0); //ios_base::sync_with_stdio(0); int T = GetT(), n = GetN(), c = GetC(); for (int i = 2; i <= n; i++) { if (sit[i]) continue; for (int j = i; j <= n; j += i) sit[j] = i; } for (int i = 1; i <= n; i++) { vector <int> d; int a = i; while (a > 1) { d.push_back(sit[a]); a /= sit[a]; } int cur = 0, r = 1; for (int j = 0; j < d.size(); j++) { if (j + 1 < d.size() && d[j] == d[j + 1]) { cur++; continue; } r *= (cur + 2); cur = 0; } dzi[i] = r; } while (T--) { int t[105], m = min(20LL, c); set <int> cand; for (int i = 0; i < m; i++) t[i] = Ask(i); for (int i = 1; i <= n; i++) { int j; for (j = 0; j < m; j++) if (t[j] != dzi[i + j]) break; if (j == m) { cand.insert(i); } } for (int i = m; i <= c && cand.size() > 1; i++) { int d = Ask(i); for (auto it = cand.begin(); it != cand.end();) { if (dzi[*it + i] != d) cand.erase(it++); else it++; } } Answer(*cand.begin()); } }
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 | //#define _CRT_SECURE_NO_WARNINGS #include <iostream> #include <vector> #include <set> #include <fstream> #include "dzilib.h" #define int long long using namespace std; const int M = 1000005; int sit[M], dzi[M]; int32_t main() { //cin.tie(0); //cout.tie(0); //ios_base::sync_with_stdio(0); int T = GetT(), n = GetN(), c = GetC(); for (int i = 2; i <= n; i++) { if (sit[i]) continue; for (int j = i; j <= n; j += i) sit[j] = i; } for (int i = 1; i <= n; i++) { vector <int> d; int a = i; while (a > 1) { d.push_back(sit[a]); a /= sit[a]; } int cur = 0, r = 1; for (int j = 0; j < d.size(); j++) { if (j + 1 < d.size() && d[j] == d[j + 1]) { cur++; continue; } r *= (cur + 2); cur = 0; } dzi[i] = r; } while (T--) { int t[105], m = min(20LL, c); set <int> cand; for (int i = 0; i < m; i++) t[i] = Ask(i); for (int i = 1; i <= n; i++) { int j; for (j = 0; j < m; j++) if (t[j] != dzi[i + j]) break; if (j == m) { cand.insert(i); } } for (int i = m; i <= c && cand.size() > 1; i++) { int d = Ask(i); for (auto it = cand.begin(); it != cand.end();) { if (dzi[*it + i] != d) cand.erase(it++); else it++; } } Answer(*cand.begin()); } } |