結果
問題 |
No.2324 Two Countries within UEC
|
ユーザー |
|
提出日時 | 2023-05-29 16:38:40 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 688 bytes |
コンパイル時間 | 1,071 ms |
コンパイル使用メモリ | 82,304 KB |
実行使用メモリ | 77,312 KB |
最終ジャッジ日時 | 2024-12-28 09:58:39 |
合計ジャッジ時間 | 25,563 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 12 WA * 29 |
ソースコード
N,M,P,Q = map(int,input().split()) num = P-2 num = int(bin(num)[2:]) for i in range(Q): x,f = map(int,input().split()) cels = [] res = 1 if x%P == 0: if f == 0: print(M) else: print(0) else: for j in range(0,len(str(num))): if cels == []: cels.append(x) else: cels.append((cels[-1]**2)%P) if str(num)[j] == "1": res *= cels[-1] res %= P y = (f*res)%P if y <= M and y != 0: print((M-y)//P+1) elif y == 0: print((M-y)//P) else: print(0)