結果

問題 No.2324 Two Countries within UEC
コンテスト
ユーザー lloyz
提出日時 2023-06-03 01:44:35
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 222 ms / 2,000 ms
コード長 371 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 339 ms
コンパイル使用メモリ 85,092 KB
実行使用メモリ 81,504 KB
最終ジャッジ日時 2026-03-13 22:18:10
合計ジャッジ時間 7,265 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 41
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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