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
#include <bits/stdc++.h>
#include "dzilib.h"
#define FOR(i,a,b) for(int i = a; i < b;++i)
#define pb emplace_back
#define ll long long
using namespace std;
const int maxn = 1e6 + 15005;
const int M = 1e9 + 7,p = 37;
vector<int> cnt(maxn,0);
vector<ll> pot,h;
int main(){
    FOR(i,1,maxn){
        for(int j = i; j <= maxn;j+=i){
            ++cnt[j];
        }
    }
    pot.pb(1);
    FOR(i,0,maxn){
        ll k = pot[i] * p;
        k%=M;
        pot.pb(k);
    }
    h.pb(0);
    FOR(i,1,maxn){
        ll k = (cnt[i - 1] + 1) * pot[i - 1] + h[i - 1];
        k%=M;
        h.pb(k);
    }
    int n = GetT();
    int k = GetQ();
    int c = GetC();
    int l = k / n;
    FOR(i,0,n){
        vector<int> wzo;
        FOR(j,0,l){
            wzo.pb(Ask(j));
        }
        ll wyn = 0;
        FOR(j,0,wzo.size()){
            wyn+=(wzo[j] + 1) * pot[j];
            wyn%=M;
        }
        int z1 = wzo.size();
        FOR(j,0,maxn - z1){
            ll k = h[j + z1] - h[j] + M;
            k%=M;
            if(k == wyn){
                Answer(j);
            }
            wyn*=p;
            wyn%=M;
        }
    }
}