結果
| 問題 |
No.2324 Two Countries within UEC
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-05-28 15:55:21 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 375 ms / 2,000 ms |
| コード長 | 573 bytes |
| コンパイル時間 | 354 ms |
| コンパイル使用メモリ | 81,920 KB |
| 実行使用メモリ | 77,748 KB |
| 最終ジャッジ日時 | 2024-06-26 23:27:41 |
| 合計ジャッジ時間 | 10,914 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 41 |
ソースコード
def INT():
return int(input())
def MI():
return map(int, input().split())
def LI():
return list(map(int, input().split()))
import math
N, M, P, Q = MI()
for i in range(Q):
x, f = MI()
x_inv = pow(x, P - 2, P)
y_min = ((f % P) * x_inv) % P
if y_min == 0:
y_min += P
if x % P == 0:
if f == 0:
print(M)
continue
else:
print(0)
continue
if M < y_min:
print(0)
else:
print(math.ceil((M - y_min + 1) / P))