結果

問題 No.816 Beautiful tuples
ユーザー 👑 H20H20
提出日時 2021-01-28 16:09:55
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 70 ms / 1,500 ms
コード長 463 bytes
コンパイル時間 1,049 ms
コンパイル使用メモリ 86,200 KB
実行使用メモリ 75,176 KB
最終ジャッジ日時 2023-09-08 07:01:27
合計ジャッジ時間 2,729 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
70,688 KB
testcase_01 AC 70 ms
70,812 KB
testcase_02 AC 69 ms
74,836 KB
testcase_03 AC 68 ms
75,176 KB
testcase_04 AC 69 ms
74,844 KB
testcase_05 AC 69 ms
74,724 KB
testcase_06 AC 70 ms
75,164 KB
testcase_07 AC 70 ms
74,892 KB
testcase_08 AC 69 ms
74,832 KB
testcase_09 AC 68 ms
74,864 KB
testcase_10 AC 70 ms
74,732 KB
testcase_11 AC 70 ms
74,892 KB
testcase_12 AC 70 ms
75,100 KB
testcase_13 AC 68 ms
74,768 KB
testcase_14 AC 67 ms
70,984 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]
A,B = map(int,input().split())
CD = make_divisors(A+B)
for C in CD:
    if not A==C and not B==C and (A+C)%B==0 and (B+C)%A==0:
        print(C)
        exit()

print(-1)
0