結果

問題 No.2324 Two Countries within UEC
コンテスト
ユーザー flippergo
提出日時 2026-04-14 09:06:55
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 230 ms / 2,000 ms
コード長 392 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 989 ms
コンパイル使用メモリ 84,864 KB
実行使用メモリ 81,408 KB
最終ジャッジ日時 2026-04-14 09:07:12
合計ジャッジ時間 9,907 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge3_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 41
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

N,M,P,Q = map(int,input().split())
for _ in range(Q):
    x,f = map(int,input().split())
    x = x%P
    y = (pow(x,P-2,P)*f)%P
    if x==0 and f!=0:
        print(0)
    elif x==0 and f==0:
        print(M)
    else:
        if y>M:
            print(0)
        else:
            ans = (M-y)//P+1
            if y==0:
                print(ans-1)
            else:
                print(ans)
0