結果

問題 No.2767 Add to Divide
ユーザー ニックネームニックネーム
提出日時 2024-05-31 21:41:47
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 439 ms / 2,000 ms
コード長 279 bytes
コンパイル時間 288 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 11,008 KB
最終ジャッジ日時 2024-05-31 21:41:53
合計ジャッジ時間 5,325 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
10,880 KB
testcase_01 AC 56 ms
10,752 KB
testcase_02 AC 28 ms
10,752 KB
testcase_03 AC 439 ms
10,880 KB
testcase_04 AC 28 ms
11,008 KB
testcase_05 AC 186 ms
10,752 KB
testcase_06 AC 193 ms
10,752 KB
testcase_07 AC 223 ms
10,880 KB
testcase_08 AC 349 ms
10,752 KB
testcase_09 AC 357 ms
10,752 KB
testcase_10 AC 371 ms
10,752 KB
testcase_11 AC 385 ms
10,880 KB
testcase_12 AC 350 ms
10,880 KB
testcase_13 AC 352 ms
10,752 KB
testcase_14 AC 348 ms
10,752 KB
testcase_15 AC 334 ms
10,752 KB
testcase_16 AC 350 ms
10,752 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

for _ in range(int(input())):
    a,b = map(int,input().split())
    if a==b: print(0); continue
    if 2*a>b: print(-1); continue
    c = b-a; d = []
    for i in range(1,int(c**0.5)+1):
        if c%i==0: d += [i,c//i]
    for v in sorted(d):
        if v>=a: print(v-a); break
0