結果

問題 No.2324 Two Countries within UEC
ユーザー RYOH2718RYOH2718
提出日時 2023-05-28 15:51:45
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 491 bytes
コンパイル時間 389 ms
コンパイル使用メモリ 86,872 KB
実行使用メモリ 79,444 KB
最終ジャッジ日時 2023-08-27 13:09:04
合計ジャッジ時間 13,148 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 390 ms
78,828 KB
testcase_01 AC 409 ms
78,860 KB
testcase_02 AC 167 ms
78,668 KB
testcase_03 AC 332 ms
78,944 KB
testcase_04 AC 357 ms
78,708 KB
testcase_05 AC 171 ms
78,764 KB
testcase_06 AC 215 ms
78,832 KB
testcase_07 AC 161 ms
78,716 KB
testcase_08 AC 330 ms
78,612 KB
testcase_09 AC 329 ms
78,864 KB
testcase_10 AC 402 ms
79,024 KB
testcase_11 AC 396 ms
78,796 KB
testcase_12 AC 196 ms
78,760 KB
testcase_13 AC 206 ms
79,300 KB
testcase_14 AC 173 ms
78,664 KB
testcase_15 AC 159 ms
78,556 KB
testcase_16 AC 309 ms
78,828 KB
testcase_17 AC 251 ms
79,016 KB
testcase_18 AC 167 ms
78,404 KB
testcase_19 AC 404 ms
78,692 KB
testcase_20 AC 152 ms
78,472 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 409 ms
78,960 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 73 ms
71,424 KB
testcase_32 AC 71 ms
71,384 KB
testcase_33 AC 73 ms
71,264 KB
testcase_34 AC 73 ms
71,672 KB
testcase_35 AC 74 ms
71,220 KB
testcase_36 AC 74 ms
71,220 KB
testcase_37 AC 71 ms
71,624 KB
testcase_38 AC 73 ms
71,424 KB
testcase_39 AC 73 ms
71,284 KB
testcase_40 AC 72 ms
71,280 KB
testcase_41 WA -
testcase_42 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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 * x_inv) % P

    if y_min == 0:
        y_min += P

    if f == 0 and x % P == 0:
        print(M)
        continue

    if M < y_min:
        print(0)
    else:
        print(math.ceil((M - y_min + 1) / P))
0