#GL0000394. Ước chung lớn nhất của số nguyên Gauss (Gcd of Gaussian Integers)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Ước chung lớn nhất của số nguyên Gauss (Gcd of Gaussian Integers)
Gcd of Gaussian Integers
Source: Library Checker
Version: Phuoc Hung OJ Extended
Problem Statement
A Gaussian integer is a complex number with integer and .
Given and , print any greatest common divisor in : divides both inputs and every common Gaussian divisor divides .
Answers are not unique. Whenever is a valid answer, are also valid. When both inputs equal zero, the answer is .
Input
Four integers on one line. PHOJ uses one input pair per file, unlike the source's multi-case wrapper.
Output
Two integers representing one valid Gaussian GCD. The special checker accepts all four unit multiples.
Subtasks
-
Subtask 1 (20 points): .
-
Subtask 2 (30 points): .
-
Subtask 3 (50 points): .
Examples
Example 1
Input
11 3 1 8
Output
2 1
Explanation
and , so divides both. Its three unit multiples are also accepted.
Example 2
Input
6 0 0 4
Output
2 0
Explanation
Both and are divisible by the Gaussian integer . Outputting , , or is equally correct.