問題一覧 > 通常問題

No.442 Sum and Product

レベル : / AI推定難易度 : 1100 / 実行時間制限 : 1ケース 1.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 421
作問者 : ctyl_0 / テスター : 🍡yurahuna
お気に入りにしたユーザー ProblemId : 1228 / 自分の提出
問題文最終更新日: 2026-06-27 07:52:25
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もしくは右上の雲マークをクリックしてアカウントを作成してください。