結果

問題 No.2568 列辞書順列列
ユーザー titiatitia
提出日時 2023-12-21 02:33:02
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,092 ms / 3,000 ms
コード長 313 bytes
コンパイル時間 89 ms
コンパイル使用メモリ 11,904 KB
実行使用メモリ 33,272 KB
最終ジャッジ日時 2023-12-21 02:33:29
合計ジャッジ時間 26,536 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
9,984 KB
testcase_01 AC 28 ms
9,984 KB
testcase_02 AC 677 ms
10,112 KB
testcase_03 AC 660 ms
10,112 KB
testcase_04 AC 962 ms
19,924 KB
testcase_05 AC 938 ms
19,916 KB
testcase_06 AC 959 ms
19,920 KB
testcase_07 AC 950 ms
19,916 KB
testcase_08 AC 941 ms
19,916 KB
testcase_09 AC 973 ms
33,272 KB
testcase_10 AC 955 ms
33,272 KB
testcase_11 AC 970 ms
33,272 KB
testcase_12 AC 1,092 ms
33,272 KB
testcase_13 AC 1,090 ms
33,272 KB
testcase_14 AC 1,064 ms
33,272 KB
testcase_15 AC 1,089 ms
33,272 KB
testcase_16 AC 1,086 ms
33,272 KB
testcase_17 AC 882 ms
33,272 KB
testcase_18 AC 908 ms
33,272 KB
testcase_19 AC 885 ms
33,272 KB
testcase_20 AC 906 ms
33,272 KB
testcase_21 AC 900 ms
33,272 KB
testcase_22 AC 888 ms
33,272 KB
testcase_23 AC 888 ms
33,272 KB
testcase_24 AC 878 ms
33,272 KB
testcase_25 AC 905 ms
33,272 KB
testcase_26 AC 889 ms
33,272 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,M,Q=map(int,input().split())
A=list(map(int,input().split()))

mod=998244353
INV=pow(M,mod-2,mod)
S=[0]*(N+1)

x=1

for i in range(N-1,-1,-1):
    S[i]=(S[i+1]+x*(A[i]-1))%mod
    x=x*M%mod

for tests in range(Q):
    l,r=map(int,input().split())
    ANS=S[l-1]-S[r]

    print((ANS*pow(INV,N-r,mod)%mod+1)%mod)
0