結果

問題 No.816 Beautiful tuples
ユーザー tomarint2tomarint2
提出日時 2019-04-19 21:42:17
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 440 bytes
コンパイル時間 1,008 ms
コンパイル使用メモリ 81,704 KB
実行使用メモリ 57,464 KB
最終ジャッジ日時 2023-10-24 00:51:59
合計ジャッジ時間 1,742 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 38 ms
53,704 KB
testcase_02 AC 41 ms
57,464 KB
testcase_03 WA -
testcase_04 AC 41 ms
57,464 KB
testcase_05 AC 41 ms
57,464 KB
testcase_06 AC 42 ms
57,464 KB
testcase_07 AC 41 ms
57,464 KB
testcase_08 AC 42 ms
57,464 KB
testcase_09 AC 42 ms
57,464 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 42 ms
57,464 KB
testcase_13 AC 41 ms
57,464 KB
testcase_14 AC 39 ms
53,704 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# A+B=n*C
# B+C=m*A
# C+A=l*B
# 2 * (A+B+C) = n*C + m*A + l*B
def divisor(n):
    n2 = int((n**0.5)+1) + 1
    ret = set()
    for i in range(1,n2):
        if n%i==0:
            ret.add(i)
            ret.add(n//i)
    ret = list(ret)
    ret.sort()
    return ret

def solve():
    A,B=map(int,input().split())
    Cs=divisor(A+B)
    for c in Cs:
        if (B+c)%A==0 and (c+A)%B==0:
            return c
    return -1

print(solve())
0