結果

問題 No.2767 Add to Divide
ユーザー june19312june19312
提出日時 2024-05-31 22:57:31
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 490 bytes
コンパイル時間 231 ms
コンパイル使用メモリ 82,400 KB
実行使用メモリ 67,264 KB
最終ジャッジ日時 2024-05-31 22:57:35
合計ジャッジ時間 4,063 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 194 ms
67,264 KB
testcase_01 TLE -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

T = int(input())
#4394 993298361
for j in range(T):
    a,b = map(int,input().split())
    if b%a == 0:
        print(0)
        continue
    elif b//a < 2:
        print(-1)
        continue

    for k in range(b//a,1,-1):
        ok,ng = 0,10**10

        while abs(ok-ng) > 1:
            mid = abs((ok+ng)//2)
            if (b+mid)//(a+mid) < k:
                ng = mid
            else:
                ok = mid

        if (b+ok)%(a+ok) == 0:
            print(ok)
            break
0