-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path766d.cpp
44 lines (36 loc) · 780 Bytes
/
766d.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
43
44
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pi = pair<ll, ll>;
using vi = vector<ll>;
using vpi = vector<pi>;
using vb = vector<bool>;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll n;
cin >> n;
vi a(n);
vi vis(1e6+8);
ll mx = 0;
ll ans = 0;
for (ll i = 0; i < n; i++) {
cin >> a[i];
mx = max(mx, a[i]);
vis[a[i]] = true;
}
for (ll g = 1; g <= mx; g++) {
ll cur = 0;
for (ll m = g; m <= mx; m += g) {
if(vis[m]) {
cur = __gcd(cur, m);
if(cur == g) {
ans++;
break;
}
}
}
}
cout << ans - n << endl;
return 0;
}