-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCPP0218.cpp
More file actions
40 lines (39 loc) · 1005 Bytes
/
CPP0218.cpp
File metadata and controls
40 lines (39 loc) · 1005 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
#include <bits/stdc++.h>
#define MAX 10000001
#define ll long long
#define fastsync() \
ios_base::sync_with_stdio(false); \
cin.tie(NULL); \
cout.tie(NULL);
const int mod = 1e9 + 7;
using namespace std;
int main() {
fastsync();
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
int cnt = 0, ans = 0, j = 1, a[n];
for (int i = 0; i < n; ++i)
cin >> a[i];
if (n)
while (a[j] == a[j - 1])
++j;
ans = abs(a[j - 1] - a[j]);
for (int i = j + 1; i < n; ++i)
ans = __gcd(ans, abs(a[i] - a[i - 1]));
if (j == n)
ans = 0;
double sq = sqrt(ans);
for (int i = 1; i <= sq; ++i) {
if (ans % i == 0) {
cnt++;
if (ans / i != i)
cnt++;
}
}
cout << cnt << endl;
}
return 0;
}