프로그램 명: coci_zadaca
제한시간: 1 초
[요약]
미코는 두 수 A,B 의 최대 공약수를 구하는 숙제를 받았다.
수가 너무 커서 선생님은 그에서 곱이 A 인 N 개의 수와 곱이 B 인 M 개의 수를 주었다.
두 수 A,B 의 최대 공약수를 구하라. 9 자리 보다 커지면 마지막 9 자리만을 출력한다.
Mirko has received a homework assignment to compute the greatest common divisor of the two
positive integers A and B. Since the numbers are quite large, the teacher provided him with N smaller
integers whose product is A, and M integers with product B.
Mirko would like to verify his result, so he has asked you to write a program to solve his problem.
If the result is more than 9 digits long, output only the last 9 digits.
입력
-
The first line of input contains the positive integer N (1 ≤ N ≤ 1000).
-
The second line of input contains N space-separated positive integers less than 1 000 000 000, whose product is the number A.
-
The third line of input contains the positive integer M (1 ≤ M ≤ 1000).
-
The fourth line of input contains M space-separated positive integers less than 1 000 000 000, whose
product is the number B.
출력
The first and only line of output must contain the greatest common divisor of numbers A and B. If the
result is more than 9 digits long, output only the last (least significant) 9 digits.
입출력 예
input
3
2 3 5
2
4 5
output
10
input
4
6 2 3 4
1
1
output
1
input
3
358572 83391967 82
3
50229961 1091444 8863
output
000012028
First sample description: The greatest common divisor of numbers A = 30 and B = 20 equals 10.
출처:coci
[질/답]
[제출 현황]
[푼 후(0)]