forked from 21171-somesh/CodeforcesSolutions
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1203C.cpp
More file actions
45 lines (37 loc) · 674 Bytes
/
1203C.cpp
File metadata and controls
45 lines (37 loc) · 674 Bytes
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 <iostream>
#include <math.h>
#include <algorithm>
using namespace std;
long long arr[4*(int)1e5 + 5];
int main() {
int n;
long long mn = 1e12 + 5;
long long mn2 = mn;
scanf("%d", &n);
for (int i = 0; i < n; ++i)
{
scanf("%lld", &arr[i]);
if (arr[i]<mn) {
mn = arr[i];
mn2 = mn;
}
else if (arr[i]<mn2) {
mn2 = arr[i];
}
}
long long mini = __gcd(mn,mn2);
for (int i = 0; i < n; ++i)
{
if (arr[i]%mini==0) continue;
mini = __gcd(arr[i],mini);
}
long long count = 0;
for (int i = 1; i <= sqrt(mini); ++i)
{
if (mini%i==0) {
if (mini/i==i) count++;
else count += 2;
}
}
printf("%lld\n", count);
}