#include "dzilib.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; const ll stala = 17; ll sito[1000011+stala]; ll iledzielnikow[1000011+stala]; map<vector<int>,int > xd; ll policz_dzielnik(ll x, vector<ll> & primes){ ll wy = 1; for (ll p : primes){ if (x <= p) break; ll akt = 0; while (!(x%p)){ akt++; x /= p; } } return wy; } const ll duzo = 1000010000; const ll malo = 50; signed main(){ ios_base::sync_with_stdio(0); cin.tie(0); ll i; ll t = GetT(); ll n = GetN(); ll q = GetQ(); ll c = GetC(); if (n <= 1000000){ for (i = 2; i <= 1000000+stala+1; i++){ if (sito[i]) continue; for (ll j = i; j <= 1000000+stala+1; j += i) sito[j] = i; } for (i = 1; i <= 1000000+stala+1; i++){ iledzielnikow[i] = 1; ll x = i; while (x != 1){ ll y = sito[x]; ll wyk = 0; while (!(x%y)){ x /= y; wyk++; } iledzielnikow[i] *= (wyk+1); } } for (i = 1; i <= 1000000; i++){ vector<int> moje; for (ll j = 0; j < stala; j++) moje.push_back(iledzielnikow[i+j]); xd[moje] = i; } while (t--){ vector<int> akt; for (i = 0; i < stala; i++) akt.push_back(Ask(i)); Answer(xd[akt]); } return 0; } vector<ll> primes; for (i = 2; i*i <= duzo; i++){ if (sito[i]) continue; primes.push_back(i); for (ll j = i; j*j <= duzo; j += i) sito[j] = i; } for (i = 1; i <= 1000000000+4810; i += 4800){ vector<int> moje(malo,1); vector<ll> zostalo(malo); for (ll j = 0; j < malo; j++) zostalo[j] = i+j; for (ll p : primes){ for (ll j = (i+p-1)/p*p; j < i+malo; j += p){ ll krotnosc = 0; while (zostalo[j-i]%p == 0){ krotnosc++; zostalo[j-i] /= p; } //cout<<p<<" dzieli "<<j<<" w krotnosci "<<krotnosc<<"\n"; moje[j-i] *= krotnosc+1; } } for (int j = 0; j < malo; j++) if (zostalo[j] != 1) moje[j]++; xd[moje] = i; } while (t--){ vector<int> odp; for (int j = 0; j < 5000; j++) odp.push_back(Ask(j)); for (int j = 0; j < 4800; j++){ vector<int> akt; for (int k = 0; k < malo; k++) akt.push_back(odp[j+k]); if (xd.find(akt) != xd.end()){ Answer(xd[akt]-j); 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 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 "dzilib.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; const ll stala = 17; ll sito[1000011+stala]; ll iledzielnikow[1000011+stala]; map<vector<int>,int > xd; ll policz_dzielnik(ll x, vector<ll> & primes){ ll wy = 1; for (ll p : primes){ if (x <= p) break; ll akt = 0; while (!(x%p)){ akt++; x /= p; } } return wy; } const ll duzo = 1000010000; const ll malo = 50; signed main(){ ios_base::sync_with_stdio(0); cin.tie(0); ll i; ll t = GetT(); ll n = GetN(); ll q = GetQ(); ll c = GetC(); if (n <= 1000000){ for (i = 2; i <= 1000000+stala+1; i++){ if (sito[i]) continue; for (ll j = i; j <= 1000000+stala+1; j += i) sito[j] = i; } for (i = 1; i <= 1000000+stala+1; i++){ iledzielnikow[i] = 1; ll x = i; while (x != 1){ ll y = sito[x]; ll wyk = 0; while (!(x%y)){ x /= y; wyk++; } iledzielnikow[i] *= (wyk+1); } } for (i = 1; i <= 1000000; i++){ vector<int> moje; for (ll j = 0; j < stala; j++) moje.push_back(iledzielnikow[i+j]); xd[moje] = i; } while (t--){ vector<int> akt; for (i = 0; i < stala; i++) akt.push_back(Ask(i)); Answer(xd[akt]); } return 0; } vector<ll> primes; for (i = 2; i*i <= duzo; i++){ if (sito[i]) continue; primes.push_back(i); for (ll j = i; j*j <= duzo; j += i) sito[j] = i; } for (i = 1; i <= 1000000000+4810; i += 4800){ vector<int> moje(malo,1); vector<ll> zostalo(malo); for (ll j = 0; j < malo; j++) zostalo[j] = i+j; for (ll p : primes){ for (ll j = (i+p-1)/p*p; j < i+malo; j += p){ ll krotnosc = 0; while (zostalo[j-i]%p == 0){ krotnosc++; zostalo[j-i] /= p; } //cout<<p<<" dzieli "<<j<<" w krotnosci "<<krotnosc<<"\n"; moje[j-i] *= krotnosc+1; } } for (int j = 0; j < malo; j++) if (zostalo[j] != 1) moje[j]++; xd[moje] = i; } while (t--){ vector<int> odp; for (int j = 0; j < 5000; j++) odp.push_back(Ask(j)); for (int j = 0; j < 4800; j++){ vector<int> akt; for (int k = 0; k < malo; k++) akt.push_back(odp[j+k]); if (xd.find(akt) != xd.end()){ Answer(xd[akt]-j); break; } } } return 0; } |