You are given an array aa consisting of nn integers.
Your task is to say the number of such positive integers xx such that xx divides each number from the array. In other words, you have to find the number of common divisors of all elements in the array.
For example, if the array aa will be [2,4,6,2,10][2,4,6,2,10], then 11 and 22 divide each number from the array (so the answer for this test is 22).
The first line of the input contains one integer nn (1≤n≤4⋅1051≤n≤4⋅105) — the number of elements in aa.
The second line of the input contains nn integers a1,a2,…,ana1,a2,…,an (1≤ai≤10121≤ai≤1012), where aiai is the ii-th element of aa.
Print one integer — the number of such positive integers xx such that xx divides each number from the given array (in other words, the answer is the number of common divisors of all elements in the array).
5 1 2 3 4 5
1
6 6 90 12 18 30 18
4
#include <bits/stdc++.h> #include <iostream> #include <algorithm> #include <cstdio> #include <string> #include <cstring> #include <cstdlib> #include <map> #include <vector> #include <set> #include <queue> #include <stack> #include <cmath> typedef long long ll; using namespace std; const int INT=1e6+5; #define lson rt<<1, l, m #define rson rt<<1|1, m+1, r #define read(x) scanf("%d",&x) #define lread(x) scanf("%lld",&x); #define pt(x) printf("%d\n",(x)) #define cn cin>> #define ct cout<< #define en <<endl #define rep(j,k) for (int i = (int)(j); i <= (int)(k); i++) #define mem(s,t) memset(s,t,sizeof(s)) #define re return 0; #define TLE std::ios::sync_with_stdio(false); ll a[100000+5],b[10000+5]; priority_queue<ll>q1,q2; int main() { TLE; ll t,n,m,mx,flag,k=0,cnt=0; cn n; rep(1,n) { cn m; k=__gcd(m,k); //库函数 } rep(1,sqrt(k)) { if(k%i) continue; else { cnt++; if(i!=k/i) cnt++; //计数 sqrt(k) 右边的公约数,也是一种优化 } } ct cnt en; re ; }