結果
| 問題 |
No.2767 Add to Divide
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-06-04 05:05:23 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 524 bytes |
| コンパイル時間 | 295 ms |
| コンパイル使用メモリ | 82,176 KB |
| 実行使用メモリ | 60,544 KB |
| 最終ジャッジ日時 | 2024-12-23 10:47:33 |
| 合計ジャッジ時間 | 1,926 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 12 WA * 4 |
ソースコード
def divisors(n):
res_low, res_high = [], []
i = 1
while i * i <= n:
if n % i == 0:
res_low.append(i)
if i != n // i:
res_high.append(n // i)
i += 1
return res_low + res_high[::-1]
def f(dv, a):
for x in dv:
if a <= x:
return x
return -1
T = int(input())
for t in range(T):
a, b = map(int, input().split())
dv = divisors(b-a)
res = f(dv, a)
if res == -1:
print(-1)
else:
print(res - a)