結果

問題 No.2568 列辞書順列列
ユーザー KoiKoi
提出日時 2023-12-02 15:16:05
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 217 ms / 3,000 ms
コード長 387 bytes
コンパイル時間 399 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 131,044 KB
最終ジャッジ日時 2023-12-02 15:16:14
合計ジャッジ時間 7,812 ms
ジャッジサーバーID
(参考情報)
judge10 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 33 ms
53,460 KB
testcase_01 AC 35 ms
53,460 KB
testcase_02 AC 113 ms
79,592 KB
testcase_03 AC 112 ms
79,592 KB
testcase_04 AC 177 ms
131,036 KB
testcase_05 AC 175 ms
131,040 KB
testcase_06 AC 194 ms
131,040 KB
testcase_07 AC 195 ms
131,040 KB
testcase_08 AC 168 ms
131,044 KB
testcase_09 AC 177 ms
119,792 KB
testcase_10 AC 178 ms
119,792 KB
testcase_11 AC 179 ms
119,792 KB
testcase_12 AC 217 ms
119,792 KB
testcase_13 AC 192 ms
119,792 KB
testcase_14 AC 198 ms
119,792 KB
testcase_15 AC 189 ms
119,792 KB
testcase_16 AC 198 ms
119,792 KB
testcase_17 AC 205 ms
119,792 KB
testcase_18 AC 182 ms
119,792 KB
testcase_19 AC 177 ms
119,792 KB
testcase_20 AC 182 ms
119,792 KB
testcase_21 AC 172 ms
119,664 KB
testcase_22 AC 198 ms
119,792 KB
testcase_23 AC 199 ms
119,792 KB
testcase_24 AC 174 ms
119,792 KB
testcase_25 AC 179 ms
119,792 KB
testcase_26 AC 184 ms
119,792 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

Mod=998244353
N,M,Q=map(int,input().split())
A=list(map(int,input().split()))
for i in range(N):
    A[i]-=1
pow_M=[1]
for i in range(N):
    pow_M.append(pow_M[-1]*M%Mod)
S=[0]
for i in range(N):
    S.append((S[-1]*M+A[i])%Mod)
# print(S)
answers=[]
for i in range(Q):
    l,r=map(int,input().split())
    answers.append((S[r]-S[l-1]*pow_M[r-l+1]+1)%Mod)
for a in answers:
    print(a)
0