-
Notifications
You must be signed in to change notification settings - Fork 1
/
B.cpp
42 lines (33 loc) · 771 Bytes
/
B.cpp
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>
using namespace std;
#define ll long long
vector <ll> dv[100009];
ll ase[100009];
int main()
{
for(ll i = 1; i <= 100005; i++) {
for(ll j = i; j <= 100005; j += i)
dv[j].push_back(i);
}
ll n;
cin >> n;
for(ll i = 1; i <= n; i++) {
ll x, y;
scanf("%lld %lld", &x, &y);
ll ans = 0;
for(ll j = 0; j < dv[x].size(); j++) {
ll l = i - y, r = i - 1;
if(!(ase[dv[x][j]] >= l && ase[dv[x][j]] <= r) )
ans++;
ase[dv[x][j]] = i;
}
if(y == 0) {
printf("%lld\n", (ll)(dv[x].size()));
continue;
}
else {
printf("%lld\n", ans);
}
}
return 0;
}