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
#include<bits/stdc++.h>
using namespace std;
using ll = long long;

vector<int> gens(int n, int x = 0){
    static vector<int>V(n+9);
    if(!x){
        for(int i = 2; i <= n; i++){
            if(V[i] == 0){
                V[i] = i;
                for(int j = i*2; j <= n; j+=i)V[j] = i;
            }
        }
        return {};
    }
    else{
        if(x == 1)return {}; 
        vector<int>W = {V[x]};
        x /= V[x];
        while(x > 1){
            if(W.back() != V[x]){
                W.push_back(V[x]);
                // cout << V[x] << endl;   
            }
            x /= V[x];
        }
        return W;
    }
}
const int SIZE = (1 << 24);
int tree[SIZE * 2];
void update(int v,int x){
    v += SIZE;
    while(v > 0){
        tree[v] += x;
        v /= 2;
    }
}
int main(){
    int n, q;
    cin >> n >> q;
    gens(n);
    // for(auto x : gens(n,7))cout << x << ' ';
    vector<bool>c(n);
    int pie = 0;
    while(q--){
        int a;
        cin >> a;
        a--;
        if(a == 0){
            pie ^= 1;
            cout << tree[1] + pie << '\n';
            continue;
        }
    
        // cout << a << endl;
        auto X = gens(n,a);
        for(auto x : X){
            if(c[a])update(x,-1);
            else update(x,1);
        }
        if(c[a])c[a] = 0;
        else c[a] = 1;
        cout << tree[1] + pie << '\n';
    }
}