結果

問題 No.2568 列辞書順列列
ユーザー hirayuu_ychirayuu_yc
提出日時 2023-12-02 14:59:25
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 425 ms / 3,000 ms
コード長 261 bytes
コンパイル時間 399 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 108,288 KB
最終ジャッジ日時 2024-09-26 17:50:20
合計ジャッジ時間 12,799 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
51,840 KB
testcase_01 AC 40 ms
51,712 KB
testcase_02 AC 307 ms
76,544 KB
testcase_03 AC 306 ms
76,288 KB
testcase_04 AC 361 ms
105,216 KB
testcase_05 AC 365 ms
105,088 KB
testcase_06 AC 367 ms
105,088 KB
testcase_07 AC 374 ms
105,344 KB
testcase_08 AC 370 ms
105,472 KB
testcase_09 AC 385 ms
108,160 KB
testcase_10 AC 388 ms
107,648 KB
testcase_11 AC 387 ms
108,032 KB
testcase_12 AC 422 ms
107,904 KB
testcase_13 AC 419 ms
107,520 KB
testcase_14 AC 425 ms
108,160 KB
testcase_15 AC 420 ms
107,648 KB
testcase_16 AC 415 ms
108,288 KB
testcase_17 AC 394 ms
108,288 KB
testcase_18 AC 401 ms
107,776 KB
testcase_19 AC 400 ms
107,648 KB
testcase_20 AC 404 ms
108,032 KB
testcase_21 AC 399 ms
107,904 KB
testcase_22 AC 399 ms
107,776 KB
testcase_23 AC 398 ms
107,904 KB
testcase_24 AC 395 ms
108,032 KB
testcase_25 AC 397 ms
108,288 KB
testcase_26 AC 401 ms
107,648 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