PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#GL0000212. Ước chung lớn nhất của hai tích khổng lồ (HUGE GCD)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Ước chung lớn nhất của hai tích khổng lồ (HUGE GCD)
Ước chung lớn nhất của hai tích khổng lồ (HUGE GCD)
Source: SPOJ
Version: Phuoc Hung OJ Extended
Problem Statement
Two positive integers and are supplied as lists of factors because their values may be extremely large. Find . Print normally if it has at most nine decimal digits. Otherwise print exactly the last nine digits, keeping any leading zeros of this nine-digit suffix.
Input
Line 1: . Line 2: factors . Line 3: . Line 4: factors .
Output
Print the result on one line, respecting the nine-digit suffix formatting rule.
Subtasks
-
Subtask 1 (20 points): ; .
-
Subtask 2 (30 points): ; .
-
Subtask 3 (50 points): ; .
Examples
Example 1
Input
3
2 3 5
2
4 5
Output
10
Explanation
The products are 30 and 20; their GCD is 10.
Example 2
Input
3
358572 83391967 82
3
50229961 1091444 8863
Output
000012028
Explanation
The GCD has more than nine decimal digits. Its last nine digits are 000012028; leading zeroes must be retained.