포럼
문제 COCI00201

Zadaća

설명

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 \le N \le 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 \le M \le 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.

Note: In the third sample, the result has more than \(9\) digits, so only the last \(9\) digits (with leading zeros) are printed.

서브태스크
서브태스크점수설명

Test 1

10점

None

Test 2

10점

None

Test 3

10점

None

Test 4

10점

None

Test 5

10점

None

Test 6

10점

None

Test 7

10점

None

Test 8

10점

None

Test 9

10점

None

Test 10

10점

None

예제 1
입력
3
2 3 5
2
4 5
출력
10
예제 2
입력
4
6 2 3 4
1
1
출력
1
예제 3
입력
3
358572 83391967 82
3
50229961 1091444 8863
출력
000012028
문제 정보

riseoj 작성

출처 COCI 2011/2012 Contest 2

평가 및 의견

Zadaća

개요
출제자 난이도 Unrated 레이팅 미적용 의견 0 / 1 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

Zadaća

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8