CF1203C Common Divisors

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 eachnumber 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).

Input

The first line of the input contains one integer nn (1n41051≤n≤4⋅105) — the number of elements in aa.

The second line of the input contains nn integers a1,a2,,ana1,a2,…,an (1ai10121≤ai≤1012), where aiai is the ii-th element of aa.

Output

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).

Examples

Input
5
1 2 3 4 5
Output
1
Input
6
6 90 12 18 30 18
Output
4 
meaning of the questions: Find the number of the number of array Convention;
ideas: first find the greatest common divisor of this array with gcd, then as long as the divisor is also the array can be the greatest common divisor divisible, then if the direct traversal time out,
so the greatest common divisor of evolution, then traverse again from 2 to find out the number is divisible by then ++, because sqrt equivalent divided equally, so sqrt right end is the greatest common divisor divisible left with is the same, so you have to take 2,
and then special judge what could be the greatest common divisor is not divisible by sqrt (1 if the greatest common divisor is also special sentence)
#include <bits / STDC ++ H.> 
the using namespace STD; 
typedef Long Long LL; 
LL GCD (A LL, LL B) // greatest common divisor 
{ 
	LL C; 
	the while (B> 0) { 
		C = A% B; 
		B = A; 
		B = C; 
	} 
	return A; 
} 
int main () 
{ 
  LL n-, I; 
  LL ANS = 0; 
  LL X, m = 0; 
  CIN n->>; 
  for (I =. 1; I <= n- ; I ++) { 
	Scanf ( "% I64d", & X); 
	m = GCD (m, X); 
  } 
  Double Y = sqrt (m); 
  for (I = 2; I <Y; I ++) { 
	IF (m% I 0 ==) 
     ANS ++; 
  } 
    ANS * = 2; // on both sides, it is multiplied by two to obtain 
    if ((int) y == y && m = 1) {// Analyzing sqrt is not divisible!  
        ANS ++;
    }
    if (! m = 1) { // Japanese sentence is not the greatest common divisor. 1; 
        ANS + = 2; 
    } 
    the else { 
        ANS = +. 1; 
    } 
  COUT ANS << << endl; 
  return 0; 
}

  

Guess you like

Origin www.cnblogs.com/clb123/p/11767790.html