http://codeforces.com/contest/1025/problem/B
B. Weakened Common Divisor
time limit per test
1.5 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output
During the research on properties of the greatest common divisor (GCD) of a set of numbers, Ildar, a famous mathematician, introduced a brand new concept of the weakened common divisor (WCD) of a list of pairs of integers.
For a given list of pairs of integers (a1,b1)
, (a2,b2), ..., (an,bn) their WCD is arbitrary integer greater than 1
, such that it divides at least one element in each pair. WCD may not exist for some lists.
For example, if the list looks like [(12,15),(25,18),(10,24)]
, then their WCD can be equal to 2, 3, 5 or 6 (each of these numbers is strictly greater than 1
and divides at least o