結果

問題 No.2767 Add to Divide
ユーザー titiatitia
提出日時 2024-06-01 00:49:09
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 228 ms / 2,000 ms
コード長 452 bytes
コンパイル時間 389 ms
コンパイル使用メモリ 82,328 KB
実行使用メモリ 63,560 KB
最終ジャッジ日時 2024-06-01 00:49:19
合計ジャッジ時間 4,242 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 48 ms
59,244 KB
testcase_01 AC 54 ms
59,024 KB
testcase_02 AC 130 ms
59,864 KB
testcase_03 AC 185 ms
62,900 KB
testcase_04 AC 199 ms
61,104 KB
testcase_05 AC 202 ms
60,376 KB
testcase_06 AC 200 ms
60,436 KB
testcase_07 AC 201 ms
60,880 KB
testcase_08 AC 228 ms
60,748 KB
testcase_09 AC 200 ms
61,244 KB
testcase_10 AC 202 ms
61,696 KB
testcase_11 AC 206 ms
62,136 KB
testcase_12 AC 206 ms
63,208 KB
testcase_13 AC 204 ms
63,560 KB
testcase_14 AC 205 ms
61,272 KB
testcase_15 AC 201 ms
61,336 KB
testcase_16 AC 203 ms
62,364 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

T=int(input())
for tests in range(T):
    A,B=map(int,input().split())

    if A==B:
        print(0)
        continue

    u=B-A
    L=[]

    for i in range(1,10**5):
        if u%i==0:
            L.append(i)
            L.append(u//i)

    ANS=1<<63

    for l in L:
        if l>=A:
            ANS=min(ANS,l-A)

    if ANS==1<<63:
        ANS=-1
        print(ANS)
    else:
        print(ANS)
            
0