#include "dzilib.h" #include <vector> using namespace std; int t,q,dz,i; long long n,c; int d[1005002]; vector <int> ls[300], cand; int main() { t = GetT(); q = GetQ(); c = GetC(); n = GetN(); for(int i=2; i<=(n+5000); i++) for(int k=1; (k*i)<=(n+5000); k++) d[i*k]++; for(int i=1; i<=n; i++) { d[i]++; ls[d[i]].push_back(i); } while(t--) { cand = ls[Ask(0)]; i = 1; while(cand.size() > 1) { dz = Ask(i); for(int j=0; j<cand.size(); j++) { if(d[cand[j]+i] != dz) { swap(cand[j], cand[cand.size()-1]); cand.pop_back(); j--; } } i++; } Answer(cand[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 | #include "dzilib.h" #include <vector> using namespace std; int t,q,dz,i; long long n,c; int d[1005002]; vector <int> ls[300], cand; int main() { t = GetT(); q = GetQ(); c = GetC(); n = GetN(); for(int i=2; i<=(n+5000); i++) for(int k=1; (k*i)<=(n+5000); k++) d[i*k]++; for(int i=1; i<=n; i++) { d[i]++; ls[d[i]].push_back(i); } while(t--) { cand = ls[Ask(0)]; i = 1; while(cand.size() > 1) { dz = Ask(i); for(int j=0; j<cand.size(); j++) { if(d[cand[j]+i] != dz) { swap(cand[j], cand[cand.size()-1]); cand.pop_back(); j--; } } i++; } Answer(cand[0]); } } |