結果

問題 No.816 Beautiful tuples
コンテスト
ユーザー tails1434
提出日時 2020-01-07 21:37:33
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 28 ms / 1,500 ms
コード長 543 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 672 ms
コンパイル使用メモリ 85,248 KB
実行使用メモリ 57,600 KB
最終ジャッジ日時 2026-05-16 23:19:43
合計ジャッジ時間 1,862 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 15
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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