COMD - Common Divisor
Problem Statement:
BUBT programmers face some problem. One of them is, They have some numbers and find the smallest divisor which number divided by all given numbers. They also know you are a good programmer. Can you help them ?
Input:There are multiple test cases in the input file. Each case starts with an integer n (0<n<=106) denoting the total numbers. In the next line you have n integers, i-th integer denotes the mark on i-th value (0< ith value <=1012). Input is terminated with a case where n = 0. This case should not be processed.
Output:
For each case, print the smallest divisor. Otherwise print -1. See the sample input/output for exact formatting.
Sample Input/Output:
Sample Input
Sample Output
5
1 2 3 4 5
5
15 3 9 45 30
0
-1
3Note :
1 is not count as a divisor.
Added by: | Shipu Ahamed |
Date: | 2013-08-23 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM32-GCC MAWK BC C-CLANG NCSHARP CPP14 CPP14-CLANG COBOL COFFEE D-CLANG D-DMD DART ELIXIR FANTOM FORTH GOSU GRV JS-MONKEY JULIA KTLN NIM OBJC OBJC-CLANG OCT PICO PROLOG PYPY PYPY3 R RACKET RUST CHICKEN SQLITE SWIFT UNLAMBDA VB.NET |