結果
| 問題 |
No.2767 Add to Divide
|
| コンテスト | |
| ユーザー |
june19312
|
| 提出日時 | 2024-05-31 23:04:31 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 507 bytes |
| コンパイル時間 | 385 ms |
| コンパイル使用メモリ | 81,904 KB |
| 実行使用メモリ | 124,332 KB |
| 最終ジャッジ日時 | 2024-12-21 01:21:16 |
| 合計ジャッジ時間 | 22,041 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 9 WA * 1 TLE * 6 |
ソースコード
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(min(b//a,1000000),1,-1):
ok,ng = 0,1000000000
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
june19312