結果

問題 No.816 Beautiful tuples
ユーザー brthyyjpbrthyyjp
提出日時 2020-06-19 16:50:32
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 398 bytes
コンパイル時間 1,053 ms
コンパイル使用メモリ 87,272 KB
実行使用メモリ 75,924 KB
最終ジャッジ日時 2023-09-16 12:58:51
合計ジャッジ時間 3,065 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 69 ms
71,568 KB
testcase_02 AC 71 ms
75,308 KB
testcase_03 WA -
testcase_04 AC 72 ms
75,744 KB
testcase_05 AC 72 ms
75,920 KB
testcase_06 AC 72 ms
75,828 KB
testcase_07 AC 73 ms
75,248 KB
testcase_08 AC 73 ms
75,512 KB
testcase_09 AC 72 ms
75,924 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 72 ms
75,364 KB
testcase_13 AC 71 ms
75,512 KB
testcase_14 AC 68 ms
71,564 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

a, b = map(int, input().split())
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

d = make_divisors(a+b)
for c in d:
    if (a+c)%b == 0 and (b+c)%a == 0:
        print(c)
        exit()
else:
    print(-1)
0