結果
問題 | No.2767 Add to Divide |
ユーザー |
|
提出日時 | 2024-05-31 21:38:39 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 94 ms / 2,000 ms |
コード長 | 441 bytes |
コンパイル時間 | 358 ms |
コンパイル使用メモリ | 82,152 KB |
実行使用メモリ | 62,380 KB |
最終ジャッジ日時 | 2024-12-20 22:48:41 |
合計ジャッジ時間 | 2,357 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 16 |
ソースコード
from math import isqrtdef divisors(n):r = isqrt(n-1)+1small, large = [], []for i in range(1, r):if n%i == 0:small.append(i)large.append(n//i)if r**2 == n: small.append(r)return small + large[::-1]T = int(input())for _ in range(T):A, B = map(int, input().split())if A == B:print(0)continueD = divisors(B - A)for d in D:if d >= A:print(d - A)breakelse: print(-1)