結果
問題 | No.816 Beautiful tuples |
ユーザー | alexara1123 |
提出日時 | 2019-09-21 01:55:02 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 555 bytes |
コンパイル時間 | 306 ms |
コンパイル使用メモリ | 87,276 KB |
実行使用メモリ | 75,924 KB |
最終ジャッジ日時 | 2023-10-13 10:30:35 |
合計ジャッジ時間 | 2,819 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | AC | 71 ms
71,904 KB |
testcase_02 | AC | 74 ms
75,680 KB |
testcase_03 | WA | - |
testcase_04 | AC | 75 ms
75,692 KB |
testcase_05 | AC | 76 ms
75,696 KB |
testcase_06 | AC | 75 ms
75,756 KB |
testcase_07 | AC | 75 ms
75,696 KB |
testcase_08 | AC | 73 ms
75,748 KB |
testcase_09 | AC | 74 ms
75,864 KB |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | AC | 74 ms
75,924 KB |
testcase_13 | AC | 73 ms
75,768 KB |
testcase_14 | AC | 72 ms
71,632 KB |
ソースコード
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 def main(): a, b = map(int, input().split()) l = make_divisors(a + b) ans = float("inf") for c in l: if (b + c) % a == 0 and (a + c) % b == 0: ans = min(ans, c) if ans == float("inf"): print(-1) else: print(ans) if __name__ == '__main__': main()