結果

問題 No.2324 Two Countries within UEC
ユーザー lloyzlloyz
提出日時 2023-06-03 01:44:35
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 402 ms / 2,000 ms
コード長 371 bytes
コンパイル時間 1,724 ms
コンパイル使用メモリ 86,384 KB
実行使用メモリ 79,112 KB
最終ジャッジ日時 2023-09-09 06:24:52
合計ジャッジ時間 12,893 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 378 ms
78,700 KB
testcase_01 AC 402 ms
78,912 KB
testcase_02 AC 162 ms
78,372 KB
testcase_03 AC 323 ms
79,000 KB
testcase_04 AC 348 ms
78,832 KB
testcase_05 AC 165 ms
78,344 KB
testcase_06 AC 205 ms
78,768 KB
testcase_07 AC 155 ms
78,252 KB
testcase_08 AC 313 ms
78,700 KB
testcase_09 AC 322 ms
78,600 KB
testcase_10 AC 402 ms
79,036 KB
testcase_11 AC 382 ms
78,844 KB
testcase_12 AC 198 ms
79,112 KB
testcase_13 AC 202 ms
78,472 KB
testcase_14 AC 164 ms
78,428 KB
testcase_15 AC 158 ms
78,352 KB
testcase_16 AC 303 ms
78,836 KB
testcase_17 AC 245 ms
78,788 KB
testcase_18 AC 168 ms
78,448 KB
testcase_19 AC 388 ms
78,696 KB
testcase_20 AC 149 ms
78,348 KB
testcase_21 AC 294 ms
78,744 KB
testcase_22 AC 339 ms
78,784 KB
testcase_23 AC 187 ms
78,704 KB
testcase_24 AC 319 ms
78,780 KB
testcase_25 AC 392 ms
78,964 KB
testcase_26 AC 307 ms
77,556 KB
testcase_27 AC 311 ms
77,468 KB
testcase_28 AC 308 ms
77,448 KB
testcase_29 AC 307 ms
77,240 KB
testcase_30 AC 308 ms
77,336 KB
testcase_31 AC 69 ms
70,996 KB
testcase_32 AC 72 ms
71,384 KB
testcase_33 AC 70 ms
71,108 KB
testcase_34 AC 70 ms
71,508 KB
testcase_35 AC 72 ms
71,280 KB
testcase_36 AC 72 ms
71,144 KB
testcase_37 AC 73 ms
71,284 KB
testcase_38 AC 72 ms
70,996 KB
testcase_39 AC 72 ms
71,424 KB
testcase_40 AC 72 ms
71,400 KB
testcase_41 AC 70 ms
71,340 KB
testcase_42 AC 73 ms
71,100 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, m, p, q = map(int, input().split())
c, r = divmod(m, p)
for _ in range(q):
    x, f = map(int, input().split())
    if x % p == 0:
        if f % p != 0:
            print(0)
        else:
            print(m)
        continue
    y = f * pow(x, p - 2, p) % p
    if y <= r:
        ans = c + 1
    else:
        ans = c
    if y == 0:
        ans -= 1
    print(ans)
0