結果

問題 No.2324 Two Countries within UEC
ユーザー stunniita
提出日時 2023-05-28 14:05:57
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
TLE  
実行時間 -
コード長 325 bytes
コンパイル時間 467 ms
コンパイル使用メモリ 12,416 KB
実行使用メモリ 33,932 KB
最終ジャッジ日時 2024-12-26 23:21:31
合計ジャッジ時間 75,540 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 8 RE * 10 TLE * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

N,M,P,Q = map(int, input().split())

# (x * y) % P = f
# n^(P-1) mod P = 1
# given x and f, y = ?

# x * x^(P-2) mod P = 1
# x * f * x^(P-2) mod P = f

for _ in range(Q):
    x,f = map(int, input().split())
    y = f * x**(P-2) % P
    #print(f"{y=}")
    assert x * y % P == f
    if y == 0: y = P

    print((M-y)//P +1)


0