結果

問題 No.2568 列辞書順列列
ユーザー 👑 tipstar0125tipstar0125
提出日時 2024-01-08 21:32:16
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 610 ms / 3,000 ms
コード長 351 bytes
コンパイル時間 349 ms
コンパイル使用メモリ 81,572 KB
実行使用メモリ 119,664 KB
最終ジャッジ日時 2024-01-08 21:32:36
合計ジャッジ時間 18,650 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
53,460 KB
testcase_01 AC 37 ms
53,460 KB
testcase_02 AC 302 ms
76,008 KB
testcase_03 AC 322 ms
76,008 KB
testcase_04 AC 550 ms
117,340 KB
testcase_05 AC 518 ms
117,340 KB
testcase_06 AC 545 ms
117,340 KB
testcase_07 AC 526 ms
117,212 KB
testcase_08 AC 543 ms
117,340 KB
testcase_09 AC 529 ms
119,664 KB
testcase_10 AC 555 ms
119,664 KB
testcase_11 AC 535 ms
119,664 KB
testcase_12 AC 593 ms
119,664 KB
testcase_13 AC 580 ms
119,664 KB
testcase_14 AC 600 ms
119,664 KB
testcase_15 AC 582 ms
119,664 KB
testcase_16 AC 610 ms
119,664 KB
testcase_17 AC 533 ms
119,664 KB
testcase_18 AC 534 ms
119,664 KB
testcase_19 AC 532 ms
119,664 KB
testcase_20 AC 531 ms
119,664 KB
testcase_21 AC 567 ms
119,664 KB
testcase_22 AC 532 ms
119,664 KB
testcase_23 AC 558 ms
119,664 KB
testcase_24 AC 584 ms
119,664 KB
testcase_25 AC 534 ms
119,664 KB
testcase_26 AC 564 ms
119,664 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,M,Q=list(map(int,input().split()))
A=list(map(int,input().split()))
mod=998244353
A.reverse()
S=[0]
for (i,a) in enumerate(A):
    S.append((S[-1]+(a-1)*pow(M,i,mod))%mod)

for _ in range(Q):
    l,r=list(map(int,input().split()))
    ans=S[N-l+1]-S[N-r]
    ans+=mod
    ans%=mod
    ans*=pow(M,-N+r,mod)
    ans+=1
    ans%=mod
    print(ans)
    
0