結果

問題 No.2568 列辞書順列列
ユーザー hirayuu_ychirayuu_yc
提出日時 2023-12-02 14:59:25
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 381 ms / 3,000 ms
コード長 261 bytes
コンパイル時間 164 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 107,376 KB
最終ジャッジ日時 2023-12-02 14:59:41
合計ジャッジ時間 11,317 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
53,460 KB
testcase_01 AC 30 ms
53,460 KB
testcase_02 AC 272 ms
75,892 KB
testcase_03 AC 269 ms
75,892 KB
testcase_04 AC 323 ms
104,856 KB
testcase_05 AC 309 ms
104,856 KB
testcase_06 AC 311 ms
104,856 KB
testcase_07 AC 310 ms
104,856 KB
testcase_08 AC 326 ms
104,856 KB
testcase_09 AC 322 ms
107,376 KB
testcase_10 AC 332 ms
107,376 KB
testcase_11 AC 321 ms
107,376 KB
testcase_12 AC 368 ms
107,376 KB
testcase_13 AC 381 ms
107,376 KB
testcase_14 AC 351 ms
107,376 KB
testcase_15 AC 350 ms
107,376 KB
testcase_16 AC 348 ms
107,376 KB
testcase_17 AC 332 ms
107,376 KB
testcase_18 AC 356 ms
107,376 KB
testcase_19 AC 329 ms
107,376 KB
testcase_20 AC 336 ms
107,376 KB
testcase_21 AC 341 ms
107,376 KB
testcase_22 AC 333 ms
107,376 KB
testcase_23 AC 337 ms
107,376 KB
testcase_24 AC 338 ms
107,376 KB
testcase_25 AC 338 ms
107,376 KB
testcase_26 AC 342 ms
107,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,M,Q=map(int,input().split())
A=list(map(int,input().split()))
aft=[0]*(N+1)
MOD=998244353
for i in range(N):
    A[i]-=1
    aft[i+1]=(aft[i]*M+A[i])%MOD
for i in range(Q):
    l,r=map(int,input().split())
    print((aft[r]-aft[l-1]*(pow(M,r-l+1,MOD))+1)%MOD)
0