PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#GL0000047. UCLN của số nhỏ và số thập phân cực lớn (GCD2)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
UCLN của số nhỏ và số thập phân cực lớn (GCD2)
GCD2
Source: SPOJ
Version: Phuoc Hung OJ Extended
Problem Statement
Given nonnegative integers , where is small and may contain very many decimal digits, compute exactly without parsing as a built-in integer. When , the answer is . If both integers are zero, define the result to be .
Input
One line contains and the decimal representation of .
Output
Print the GCD as a decimal integer.
Subtasks
- Subtask 1 (20 points): ;
- Subtask 2 (30 points): ;
- Subtask 3 (50 points): ;
Examples
Input
10 11
Output
1
Explanation
Since , we obtain .