// Przykładowe niepoprawne rozwiązanie do zadania Dzielniki.
#include "dzilib.h"
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> VI;
typedef pair <int,int> ii;
typedef long long LL;
#define pb push_back
const int INF = 2147483647;
const int N = 1000017;
int i, ld[N + 5], tab[20], t, q;
LL c, n;
int compute(int w) {
int res = 1;
for (int i=2;i*i<=w;i++) if (w % i == 0) {
int act = 0;
while (w % i == 0) {
w /= i;
act++;
}
res *= (act + 1);
}
if (w != 1) res *= 2;
return res;
}
bool ok(int w) {
for (int i=0;i<17;i++) if (tab[i] != ld[w + i]) return false;
return true;
}
int main() {
for (i=1;i<=N;i++) ld[i] = compute(i);
t = GetT();
q = GetQ();
c = GetC();
n = GetN();
while (t--) {
for (i=0;i<17;i++) tab[i] = Ask(i);
for (i=1;i<=N;i++) if (ok(i)) {
Answer(i);
break;
}
}
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 | // Przykładowe niepoprawne rozwiązanie do zadania Dzielniki. #include "dzilib.h" #include <bits/stdc++.h> using namespace std; typedef vector<int> VI; typedef pair <int,int> ii; typedef long long LL; #define pb push_back const int INF = 2147483647; const int N = 1000017; int i, ld[N + 5], tab[20], t, q; LL c, n; int compute(int w) { int res = 1; for (int i=2;i*i<=w;i++) if (w % i == 0) { int act = 0; while (w % i == 0) { w /= i; act++; } res *= (act + 1); } if (w != 1) res *= 2; return res; } bool ok(int w) { for (int i=0;i<17;i++) if (tab[i] != ld[w + i]) return false; return true; } int main() { for (i=1;i<=N;i++) ld[i] = compute(i); t = GetT(); q = GetQ(); c = GetC(); n = GetN(); while (t--) { for (i=0;i<17;i++) tab[i] = Ask(i); for (i=1;i<=N;i++) if (ok(i)) { Answer(i); break; } } return 0; } |
English