結果
| 問題 | No.2324 Two Countries within UEC |
| コンテスト | |
| ユーザー |
Kude
|
| 提出日時 | 2023-05-28 13:38:30 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
AC
|
| 実行時間 | 218 ms / 2,000 ms |
| コード長 | 311 bytes |
| 記録 | |
| コンパイル時間 | 261 ms |
| コンパイル使用メモリ | 84,968 KB |
| 実行使用メモリ | 81,324 KB |
| 最終ジャッジ日時 | 2026-03-13 22:00:18 |
| 合計ジャッジ時間 | 7,242 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 41 |
ソースコード
n, m, p, q = map(int, input().split())
for _ in range(q):
x, f = map(int, input().split())
if x % p == 0:
print(m if f == 0 else 0)
else:
y = pow(x, p - 2, p) * f % p
# 1<=tp+y<=m
# 1-y<=tp<=m-y
ans = (m - y) // p - (1 - y + p - 1) // p + 1
print(ans)
Kude