結果

問題 No.2568 列辞書順列列
ユーザー lloyzlloyz
提出日時 2023-12-20 03:03:43
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 575 ms / 3,000 ms
コード長 465 bytes
コンパイル時間 310 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 109,168 KB
最終ジャッジ日時 2023-12-20 03:04:03
合計ジャッジ時間 19,500 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,460 KB
testcase_01 AC 36 ms
53,460 KB
testcase_02 AC 384 ms
75,992 KB
testcase_03 AC 395 ms
75,992 KB
testcase_04 AC 515 ms
106,692 KB
testcase_05 AC 538 ms
106,692 KB
testcase_06 AC 509 ms
106,692 KB
testcase_07 AC 520 ms
106,692 KB
testcase_08 AC 511 ms
106,692 KB
testcase_09 AC 532 ms
109,168 KB
testcase_10 AC 534 ms
109,168 KB
testcase_11 AC 533 ms
109,168 KB
testcase_12 AC 571 ms
109,168 KB
testcase_13 AC 543 ms
109,168 KB
testcase_14 AC 575 ms
109,168 KB
testcase_15 AC 546 ms
109,168 KB
testcase_16 AC 575 ms
109,168 KB
testcase_17 AC 528 ms
109,168 KB
testcase_18 AC 557 ms
109,168 KB
testcase_19 AC 528 ms
109,168 KB
testcase_20 AC 556 ms
109,168 KB
testcase_21 AC 527 ms
109,168 KB
testcase_22 AC 538 ms
109,168 KB
testcase_23 AC 526 ms
109,168 KB
testcase_24 AC 527 ms
109,168 KB
testcase_25 AC 531 ms
109,168 KB
testcase_26 AC 525 ms
109,168 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, m, q = map(int, input().split())
mod = 998244353
A = list(map(int, input().split()))

Powm = [pow(m, i, mod) for i in range(n + 1)]
accumA = [0 for _ in range(n + 1)]
for i in range(n - 1, -1, -1):
    accumA[i] = accumA[i + 1] + (A[i] - 1) * Powm[n - 1 - i] % mod
    accumA[i] %= mod
for _ in range(q):
    l, r = map(int, input().split())
    l -= 1
    ans = (accumA[l] - accumA[r]) % mod
    ans *= pow(Powm[n - r], mod - 2, mod)
    print((ans + 1) % mod)
0