結果

問題 No.2568 列辞書順列列
ユーザー けんぴんけんぴん
提出日時 2023-10-30 19:20:15
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 373 ms / 3,000 ms
コード長 439 bytes
コンパイル時間 307 ms
コンパイル使用メモリ 81,864 KB
実行使用メモリ 132,544 KB
最終ジャッジ日時 2023-10-30 19:20:30
合計ジャッジ時間 14,489 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
53,536 KB
testcase_01 AC 35 ms
53,536 KB
testcase_02 AC 267 ms
75,980 KB
testcase_03 AC 289 ms
75,984 KB
testcase_04 AC 334 ms
132,544 KB
testcase_05 AC 323 ms
132,544 KB
testcase_06 AC 326 ms
132,544 KB
testcase_07 AC 334 ms
132,544 KB
testcase_08 AC 328 ms
132,544 KB
testcase_09 AC 335 ms
121,372 KB
testcase_10 AC 358 ms
121,372 KB
testcase_11 AC 337 ms
121,372 KB
testcase_12 AC 351 ms
121,372 KB
testcase_13 AC 354 ms
121,372 KB
testcase_14 AC 373 ms
121,372 KB
testcase_15 AC 357 ms
121,372 KB
testcase_16 AC 359 ms
121,372 KB
testcase_17 AC 344 ms
121,372 KB
testcase_18 AC 335 ms
121,372 KB
testcase_19 AC 332 ms
121,372 KB
testcase_20 AC 362 ms
121,372 KB
testcase_21 AC 336 ms
121,372 KB
testcase_22 AC 343 ms
121,372 KB
testcase_23 AC 334 ms
121,372 KB
testcase_24 AC 329 ms
121,372 KB
testcase_25 AC 343 ms
121,372 KB
testcase_26 AC 333 ms
121,372 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 998244353
N,M,Q = map(int,input().split())
A = list(map(lambda x: int(x)-1, input().split()))
acc_A = [0]
e = 1
for a in A[::-1]:
    acc_A.append((acc_A[-1] + a*e) % mod)
    e = (e * M) % mod
inv_M = pow(M, mod-2, mod)
inv_M_pow = [1]
for i in range(1, N+1):
    inv_M_pow.append((inv_M_pow[-1] * inv_M) % mod)
for _ in range(Q):
    l,r = map(int, input().split())
    print(((acc_A[-l] - acc_A[-r-1]) * inv_M_pow[N-r] + 1) % mod)
0