結果

問題 No.2767 Add to Divide
ユーザー shimonohnishishimonohnishi
提出日時 2024-06-09 22:55:57
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 355 bytes
コンパイル時間 255 ms
コンパイル使用メモリ 82,536 KB
実行使用メモリ 63,708 KB
最終ジャッジ日時 2024-12-31 03:24:32
合計ジャッジ時間 2,375 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 12 WA * 4
権限があれば一括ダウンロードができます

ソースコード

diff #

for _ in range(int(input())):
    a, b = map(int, input().split())
    d = b - a
    factors = []
    for i in range(1, int(d**0.5) + 1):
        if d % i == 0:
            factors.append(i)
            factors.append(d // i)
    factors.sort()
    ans = -1
    for f in factors:
        if f >= a:
            ans = f - a
            break
    print(ans)
0