結果

問題 No.816 Beautiful tuples
ユーザー tails1434tails1434
提出日時 2020-01-07 21:37:33
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 77 ms / 1,500 ms
コード長 543 bytes
コンパイル時間 326 ms
コンパイル使用メモリ 87,344 KB
実行使用メモリ 75,924 KB
最終ジャッジ日時 2023-08-14 23:34:02
合計ジャッジ時間 2,712 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,716 KB
testcase_01 AC 73 ms
71,688 KB
testcase_02 AC 74 ms
75,708 KB
testcase_03 AC 77 ms
75,576 KB
testcase_04 AC 74 ms
75,700 KB
testcase_05 AC 77 ms
75,608 KB
testcase_06 AC 76 ms
75,624 KB
testcase_07 AC 75 ms
75,924 KB
testcase_08 AC 76 ms
75,576 KB
testcase_09 AC 76 ms
75,620 KB
testcase_10 AC 76 ms
75,516 KB
testcase_11 AC 75 ms
75,720 KB
testcase_12 AC 76 ms
75,568 KB
testcase_13 AC 75 ms
75,748 KB
testcase_14 AC 75 ms
71,720 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def divisor(n):
    ass = []
    for i in range(1,int(n**0.5)+1):
        if n%i == 0:
            ass.append(i)
            if i**2 == n:
                continue
            ass.append(n//i)
    return ass

def main():
    A, B = map(int, input().split())
    C_cand = divisor(A+B)
    sort_C = sorted(C_cand)
    for C in sort_C:
        if C in [A,B]:
            continue
        if (B + C) % A == 0 and (A + C) % B == 0 and (A + B) % C == 0:
            print(C)
            exit()

    print(-1)



if __name__ == "__main__":
    main()
0