結果
| 問題 |
No.816 Beautiful tuples
|
| コンテスト | |
| ユーザー |
toyuzuko
|
| 提出日時 | 2020-04-28 16:45:45 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 46 ms / 1,500 ms |
| コード長 | 397 bytes |
| コンパイル時間 | 219 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 10,752 KB |
| 最終ジャッジ日時 | 2024-11-24 23:23:06 |
| 合計ジャッジ時間 | 1,346 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 15 |
ソースコード
A, B = map(int, input().split())
INF = 10**18
res = INF
n = 0
while n ** 2 <= A + B:
n += 1
if (A + B) % n == 0:
if (A + n) % B == 0 and (B + n) % A == 0 and A != n and B != n:
res = min(res, n)
m = (A + B) // n
if (A + m) % B == 0 and (B + m) % A == 0 and A != m and B != m:
res = min(res, (A + B) // n)
print(res if res != INF else -1)
toyuzuko