結果
| 問題 |
No.2324 Two Countries within UEC
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-05-28 14:34:26 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 478 bytes |
| コンパイル時間 | 726 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 22,400 KB |
| 最終ジャッジ日時 | 2024-12-27 02:02:38 |
| 合計ジャッジ時間 | 43,295 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 28 WA * 9 TLE * 4 |
ソースコード
N, M, P, Q = map(int, input().split())
def mod_div(a, b, p):
return (a * pow(b, p - 2, p)) % p
ans = []
for _ in range(Q):
x, f = map(int, input().split())
y = mod_div(f, x, P)
if y == 0:
y = P
if y > M:
ans.append(0)
continue
ok = 0
ng = M
while ng - ok > 1:
mid = (ok + ng) // 2
if P * mid + y <= M:
ok = mid
else:
ng = mid
ans.append(ok + 1)
print(*ans, sep="\n")