結果

問題 No.2568 列辞書順列列
ユーザー loop0919loop0919
提出日時 2023-11-01 00:31:16
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 602 ms / 3,000 ms
コード長 451 bytes
コンパイル時間 716 ms
コンパイル使用メモリ 81,864 KB
実行使用メモリ 125,872 KB
最終ジャッジ日時 2023-11-01 00:31:35
合計ジャッジ時間 18,794 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
53,648 KB
testcase_01 AC 36 ms
53,648 KB
testcase_02 AC 278 ms
76,096 KB
testcase_03 AC 274 ms
76,096 KB
testcase_04 AC 554 ms
125,868 KB
testcase_05 AC 529 ms
125,872 KB
testcase_06 AC 550 ms
125,872 KB
testcase_07 AC 529 ms
125,872 KB
testcase_08 AC 538 ms
125,872 KB
testcase_09 AC 500 ms
119,188 KB
testcase_10 AC 501 ms
119,188 KB
testcase_11 AC 501 ms
119,188 KB
testcase_12 AC 571 ms
119,188 KB
testcase_13 AC 573 ms
119,188 KB
testcase_14 AC 602 ms
119,188 KB
testcase_15 AC 578 ms
119,188 KB
testcase_16 AC 576 ms
119,188 KB
testcase_17 AC 524 ms
119,188 KB
testcase_18 AC 528 ms
119,188 KB
testcase_19 AC 527 ms
119,188 KB
testcase_20 AC 529 ms
119,188 KB
testcase_21 AC 522 ms
119,188 KB
testcase_22 AC 523 ms
119,224 KB
testcase_23 AC 548 ms
119,188 KB
testcase_24 AC 528 ms
119,188 KB
testcase_25 AC 561 ms
119,188 KB
testcase_26 AC 525 ms
119,188 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import accumulate

MOD = 998244353

N, M, Q = map(int, input().split())
A = list(map(lambda x: int(x) - 1, input().split()))

culc_A = [(a * pow(M, N-i, MOD)) % MOD for i, a in enumerate(A, start=1)]
cum_culc_A = [0] + list(map(lambda x: x % MOD, accumulate(culc_A)))

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