A.Common Divisors
分析:求n个数的公约数
#include <bits/stdc++.h>
using namespace std;
const int N = 4e5 + 5;
long long a[N];
int n;
long long ans = 1;
bool isprime(long long u)
{
if (u < 2)
return false;
for (int i = 2; i <= u / i; i++)
{
if (u % i == 0)
return false;
}
return true;
}
int main()
{
cin >> n;
for (int i = 0; i < n; i++)
cin >> a[i];
long long x = a[0];
for (int i = 1; i < n; i++)
x = __gcd(x, a[i]);
for (int i = 2; i <= x / i; i++)
{
if (isprime(i))
{
int cnt = 0;
while (x % i == 0)
{
x /= i, cnt++;
}
ans = ans * (cnt + 1);
}
}
printf("%lld\n", x > 1 ? (ans << 1) : ans);
return 0;
}