結果
| 問題 |
No.816 Beautiful tuples
|
| コンテスト | |
| ユーザー |
yurara
|
| 提出日時 | 2019-06-09 14:05:54 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 31 ms / 1,500 ms |
| コード長 | 425 bytes |
| コンパイル時間 | 170 ms |
| コンパイル使用メモリ | 12,544 KB |
| 実行使用メモリ | 10,880 KB |
| 最終ジャッジ日時 | 2024-10-06 00:04:31 |
| 合計ジャッジ時間 | 1,250 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 15 |
ソースコード
import math
def divisors(n):
lst = []
for i in range(1, int(math.sqrt(n)) + 1):
if n % i == 0:
lst.append(i)
if i != n // i:
lst.append(n // i)
lst.sort()
return lst
A, B = map(int, input().split())
for d in filter(lambda x: x != A and x != B, divisors(A + B)):
if (A + d) % B == 0 and (B + d) % A == 0:
print(d)
break
else:
print(-1)
yurara