#include <iostream> #include <vector> #include "dzilib.h" using namespace std; void solve(int n, int q, const vector<int>& den) { vector<int> res(q); for (int i = 0; i < q; ++i) { res[i] = Ask(i); } for (int i = 1; i <= n; ++i) { bool ok = true; for (int j = 0; j < q; ++j) { if (den[i + j] != res[j]) { ok = false; break; } } if (ok) { Answer(i); return; } } } int main() { if (GetN() > 1000000000) return 0; int t = GetT(); int n = GetN(); int q = GetQ() / t; vector<int> den(n + q); for (int i = 1; i < n + q; ++i) { for (int j = 1; j * j <= i; ++j) { if (i % j == 0) { den[i] += 2; if (j * j == i) --den[i]; } } } for (int i = 0; i < t; i++) { solve(n, q, den); } 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 | #include <iostream> #include <vector> #include "dzilib.h" using namespace std; void solve(int n, int q, const vector<int>& den) { vector<int> res(q); for (int i = 0; i < q; ++i) { res[i] = Ask(i); } for (int i = 1; i <= n; ++i) { bool ok = true; for (int j = 0; j < q; ++j) { if (den[i + j] != res[j]) { ok = false; break; } } if (ok) { Answer(i); return; } } } int main() { if (GetN() > 1000000000) return 0; int t = GetT(); int n = GetN(); int q = GetQ() / t; vector<int> den(n + q); for (int i = 1; i < n + q; ++i) { for (int j = 1; j * j <= i; ++j) { if (i % j == 0) { den[i] += 2; if (j * j == i) --den[i]; } } } for (int i = 0; i < t; i++) { solve(n, q, den); } return 0; } |