結果
問題 | No.2767 Add to Divide |
ユーザー | ra5anchor |
提出日時 | 2024-06-04 05:08:21 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 104 ms / 2,000 ms |
コード長 | 671 bytes |
コンパイル時間 | 580 ms |
コンパイル使用メモリ | 82,176 KB |
実行使用メモリ | 60,288 KB |
最終ジャッジ日時 | 2024-12-23 10:47:37 |
合計ジャッジ時間 | 2,351 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 16 |
ソースコード
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 ANS = [] T = int(input()) for t in range(T): a, b = map(int, input().split()) dv = divisors(b-a) res = f(dv, a) if a == b: ANS.append(0) elif res == -1: ANS.append(-1) # print(-1) else: ANS.append(res - a) # print(res - a) for ans in ANS: print(ans) # print(*ANS)