結果
| 問題 | No.816 Beautiful tuples |
| コンテスト | |
| ユーザー |
tomarint2
|
| 提出日時 | 2019-04-19 21:40:20 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 436 bytes |
| 記録 | |
| コンパイル時間 | 184 ms |
| コンパイル使用メモリ | 82,176 KB |
| 実行使用メモリ | 59,444 KB |
| 最終ジャッジ日時 | 2024-09-22 17:35:35 |
| 合計ジャッジ時間 | 1,456 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 11 WA * 4 |
ソースコード
# 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
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())
tomarint2