#include <bits/stdc++.h>
#include "dzilib.h"
using namespace std;
const int MAXN = 1e6+30;
const long long LOG = 20;
const long long p1 = 1e9+93;
const long long p2 = 1e9+87;
const long long MOD1 = 1e9+123;
const long long MOD2 = 1e9+207;
int liczba_dzielnikow[MAXN];
map<pair<long long,long long>,int> mapa;
long long h1,h2;
int main() {
int t = GetT();
int q = GetQ();
long long c = GetC();
long long n = GetN();
//cout<<"t="<<t<<" q="<<q<<" c="<<c<<" n="<<n<<'\n';
for(int i=1;i<=n+LOG;i++) for(int j=i;j<=n+LOG;j+=i) liczba_dzielnikow[j]++;
for(int i=1;i<=n;i++){
h1=h2=0;
for(int j=i;j<=i+min(c,LOG);j++){
h1*=p1; h1+=liczba_dzielnikow[j]; h1%=MOD1;
h2*=p2; h2+=liczba_dzielnikow[j]; h2%=MOD2;
}
//cout<<i<<' '<<h1<<' '<<h2<<'\n';
mapa[{h1,h2}]=i;
}
// for(int i=1;i<=n;i++) cout<<liczba_dzielnikow[i]<<' '; cout<<'\n';
while(t--){
h1=h2=0;
for(int i=0;i<=min(LOG,c);i++){
int x=Ask(i);
h1*=p1; h1+=x; h1%=MOD1;
h2*=p2; h2+=x; h2%=MOD2;
}
// cout<<h1<<' '<<h2<<'\n';
Answer(mapa[{h1,h2}]);
}
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 | #include <bits/stdc++.h> #include "dzilib.h" using namespace std; const int MAXN = 1e6+30; const long long LOG = 20; const long long p1 = 1e9+93; const long long p2 = 1e9+87; const long long MOD1 = 1e9+123; const long long MOD2 = 1e9+207; int liczba_dzielnikow[MAXN]; map<pair<long long,long long>,int> mapa; long long h1,h2; int main() { int t = GetT(); int q = GetQ(); long long c = GetC(); long long n = GetN(); //cout<<"t="<<t<<" q="<<q<<" c="<<c<<" n="<<n<<'\n'; for(int i=1;i<=n+LOG;i++) for(int j=i;j<=n+LOG;j+=i) liczba_dzielnikow[j]++; for(int i=1;i<=n;i++){ h1=h2=0; for(int j=i;j<=i+min(c,LOG);j++){ h1*=p1; h1+=liczba_dzielnikow[j]; h1%=MOD1; h2*=p2; h2+=liczba_dzielnikow[j]; h2%=MOD2; } //cout<<i<<' '<<h1<<' '<<h2<<'\n'; mapa[{h1,h2}]=i; } // for(int i=1;i<=n;i++) cout<<liczba_dzielnikow[i]<<' '; cout<<'\n'; while(t--){ h1=h2=0; for(int i=0;i<=min(LOG,c);i++){ int x=Ask(i); h1*=p1; h1+=x; h1%=MOD1; h2*=p2; h2+=x; h2%=MOD2; } // cout<<h1<<' '<<h2<<'\n'; Answer(mapa[{h1,h2}]); } return 0; } |
English