結果
問題 | No.2324 Two Countries within UEC |
ユーザー |
|
提出日時 | 2023-05-28 16:40:25 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 1,138 ms / 2,000 ms |
コード長 | 661 bytes |
コンパイル時間 | 247 ms |
コンパイル使用メモリ | 12,416 KB |
実行使用メモリ | 10,752 KB |
最終ジャッジ日時 | 2024-06-26 23:30:12 |
合計ジャッジ時間 | 23,881 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 41 |
ソースコード
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 * pow(x,P-2,P)) % P #print(f"{y=}") #assert x * y % P == f if y == 0: y = P """ count = 0 while True: #print(f"{y=}") if y > M:break count += 1 y += P #print(f"{count=}") print(count) """ #print(f"{y=}") if x % P == 0: if f == 0: print(M) else: print(0) elif y > M: print(0) else: print((M-y)//P +1)