結果

問題 No.2324 Two Countries within UEC
ユーザー KudeKude
提出日時 2023-05-28 13:38:30
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 413 ms / 2,000 ms
コード長 311 bytes
コンパイル時間 760 ms
コンパイル使用メモリ 87,088 KB
実行使用メモリ 78,984 KB
最終ジャッジ日時 2023-09-09 06:03:32
合計ジャッジ時間 12,813 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 379 ms
78,856 KB
testcase_01 AC 413 ms
78,572 KB
testcase_02 AC 162 ms
78,372 KB
testcase_03 AC 322 ms
78,668 KB
testcase_04 AC 359 ms
78,892 KB
testcase_05 AC 165 ms
78,516 KB
testcase_06 AC 208 ms
78,484 KB
testcase_07 AC 151 ms
78,132 KB
testcase_08 AC 318 ms
78,744 KB
testcase_09 AC 321 ms
78,720 KB
testcase_10 AC 399 ms
78,604 KB
testcase_11 AC 384 ms
78,984 KB
testcase_12 AC 196 ms
78,444 KB
testcase_13 AC 192 ms
78,588 KB
testcase_14 AC 160 ms
78,436 KB
testcase_15 AC 152 ms
78,484 KB
testcase_16 AC 305 ms
78,532 KB
testcase_17 AC 234 ms
78,536 KB
testcase_18 AC 160 ms
78,392 KB
testcase_19 AC 409 ms
78,608 KB
testcase_20 AC 143 ms
78,376 KB
testcase_21 AC 294 ms
78,768 KB
testcase_22 AC 342 ms
78,576 KB
testcase_23 AC 181 ms
78,696 KB
testcase_24 AC 307 ms
78,724 KB
testcase_25 AC 395 ms
78,596 KB
testcase_26 AC 315 ms
77,468 KB
testcase_27 AC 315 ms
77,584 KB
testcase_28 AC 313 ms
77,552 KB
testcase_29 AC 312 ms
77,276 KB
testcase_30 AC 312 ms
77,492 KB
testcase_31 AC 71 ms
71,192 KB
testcase_32 AC 71 ms
71,128 KB
testcase_33 AC 69 ms
71,268 KB
testcase_34 AC 70 ms
71,400 KB
testcase_35 AC 69 ms
71,132 KB
testcase_36 AC 71 ms
71,292 KB
testcase_37 AC 69 ms
71,544 KB
testcase_38 AC 71 ms
71,300 KB
testcase_39 AC 70 ms
71,344 KB
testcase_40 AC 71 ms
71,336 KB
testcase_41 AC 70 ms
71,292 KB
testcase_42 AC 70 ms
71,224 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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