No.442 Sum and Product
問題文最終更新日: 2026-06-27 07:52:25
English (AI translation)
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence.
Back to the original
yukicoder contest 153
(順位表)
の他の問題:
Problem Statement
Given two positive integers $A,B$, find the greatest common divisor of the sum $A+B$ and the product $A\times B$.
Input
$A$ $B$
$1\leq A\leq 10^{18}, 1\leq B\leq 10^{18}$
Output
$G$
Output the greatest common divisor of $A+B$ and $A\times B$. Print a newline at the end.
Sample
Sample 1
Input
2 4
Output
2
$\gcd (2+4,2\times 4)=2$.
Sample 2
Input
7 15
Output
1
Sample 3
Input
2986298742152912 5785953812921267
Output
186643671384557
The input may not fit in a 32-bit integer.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
🍡yurahuna