結果

問題 No.2767 Add to Divide
ユーザー H3PO4H3PO4
提出日時 2024-05-31 21:45:17
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 264 ms / 2,000 ms
コード長 369 bytes
コンパイル時間 210 ms
コンパイル使用メモリ 82,576 KB
実行使用メモリ 60,444 KB
最終ジャッジ日時 2024-05-31 21:45:48
合計ジャッジ時間 4,096 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 49 ms
59,128 KB
testcase_01 AC 49 ms
60,164 KB
testcase_02 AC 83 ms
59,612 KB
testcase_03 AC 238 ms
58,568 KB
testcase_04 AC 41 ms
53,884 KB
testcase_05 AC 264 ms
59,616 KB
testcase_06 AC 236 ms
59,048 KB
testcase_07 AC 244 ms
59,348 KB
testcase_08 AC 250 ms
60,444 KB
testcase_09 AC 238 ms
59,152 KB
testcase_10 AC 242 ms
59,288 KB
testcase_11 AC 209 ms
59,744 KB
testcase_12 AC 176 ms
60,296 KB
testcase_13 AC 212 ms
59,348 KB
testcase_14 AC 209 ms
60,140 KB
testcase_15 AC 133 ms
59,916 KB
testcase_16 AC 123 ms
58,712 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def solve(A: int, B: int):
    for x in range(10**5):
        if (B + x) % (A + x) == 0:
            return x
    for n in range(10**5, 1, -1):
        if B - n * A < 0:
            continue
        if (B - n * A) % (n - 1) == 0:
            return (B - n * A) // (n - 1)
    return -1


T = int(input())
for _ in range(T):
    print(solve(*map(int, input().split())))
0