結果
問題 | No.816 Beautiful tuples |
ユーザー |
![]() |
提出日時 | 2020-01-07 21:37:33 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 43 ms / 1,500 ms |
コード長 | 543 bytes |
コンパイル時間 | 248 ms |
コンパイル使用メモリ | 82,028 KB |
実行使用メモリ | 57,600 KB |
最終ジャッジ日時 | 2024-11-23 01:12:01 |
合計ジャッジ時間 | 1,669 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 15 |
ソースコード
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()