結果

問題 No.2324 Two Countries within UEC
ユーザー RYOH2718RYOH2718
提出日時 2023-05-28 15:55:21
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 417 ms / 2,000 ms
コード長 573 bytes
コンパイル時間 1,239 ms
コンパイル使用メモリ 87,108 KB
実行使用メモリ 79,136 KB
最終ジャッジ日時 2023-09-09 06:17:11
合計ジャッジ時間 12,872 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 395 ms
79,024 KB
testcase_01 AC 417 ms
78,700 KB
testcase_02 AC 163 ms
78,564 KB
testcase_03 AC 330 ms
79,004 KB
testcase_04 AC 351 ms
78,832 KB
testcase_05 AC 171 ms
78,800 KB
testcase_06 AC 211 ms
78,508 KB
testcase_07 AC 156 ms
78,516 KB
testcase_08 AC 324 ms
78,468 KB
testcase_09 AC 331 ms
78,672 KB
testcase_10 AC 408 ms
79,096 KB
testcase_11 AC 397 ms
78,840 KB
testcase_12 AC 200 ms
78,756 KB
testcase_13 AC 201 ms
79,108 KB
testcase_14 AC 164 ms
78,784 KB
testcase_15 AC 155 ms
78,720 KB
testcase_16 AC 311 ms
78,828 KB
testcase_17 AC 241 ms
79,084 KB
testcase_18 AC 165 ms
78,428 KB
testcase_19 AC 400 ms
78,828 KB
testcase_20 AC 148 ms
78,428 KB
testcase_21 AC 299 ms
78,956 KB
testcase_22 AC 354 ms
78,828 KB
testcase_23 AC 185 ms
78,760 KB
testcase_24 AC 325 ms
79,136 KB
testcase_25 AC 403 ms
79,100 KB
testcase_26 AC 350 ms
78,764 KB
testcase_27 AC 392 ms
78,700 KB
testcase_28 AC 346 ms
78,856 KB
testcase_29 AC 346 ms
79,004 KB
testcase_30 AC 340 ms
79,080 KB
testcase_31 AC 70 ms
71,624 KB
testcase_32 AC 69 ms
71,520 KB
testcase_33 AC 69 ms
71,336 KB
testcase_34 AC 71 ms
71,260 KB
testcase_35 AC 70 ms
71,688 KB
testcase_36 AC 70 ms
71,332 KB
testcase_37 AC 70 ms
71,404 KB
testcase_38 AC 69 ms
71,336 KB
testcase_39 AC 70 ms
71,068 KB
testcase_40 AC 70 ms
71,184 KB
testcase_41 AC 68 ms
71,596 KB
testcase_42 AC 70 ms
71,192 KB
権限があれば一括ダウンロードができます

ソースコード

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 % 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))
0