結果

問題 No.2568 列辞書順列列
ユーザー hiro1729hiro1729
提出日時 2023-12-02 15:36:51
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 504 ms / 3,000 ms
コード長 371 bytes
コンパイル時間 258 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 134,180 KB
最終ジャッジ日時 2023-12-02 15:37:06
合計ジャッジ時間 14,562 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
53,460 KB
testcase_01 AC 32 ms
53,460 KB
testcase_02 AC 349 ms
75,996 KB
testcase_03 AC 339 ms
75,996 KB
testcase_04 AC 431 ms
134,180 KB
testcase_05 AC 423 ms
134,180 KB
testcase_06 AC 410 ms
134,180 KB
testcase_07 AC 441 ms
134,180 KB
testcase_08 AC 413 ms
134,180 KB
testcase_09 AC 459 ms
114,788 KB
testcase_10 AC 504 ms
114,792 KB
testcase_11 AC 459 ms
114,788 KB
testcase_12 AC 487 ms
114,408 KB
testcase_13 AC 487 ms
114,788 KB
testcase_14 AC 503 ms
114,408 KB
testcase_15 AC 471 ms
114,408 KB
testcase_16 AC 475 ms
114,404 KB
testcase_17 AC 451 ms
114,404 KB
testcase_18 AC 469 ms
114,404 KB
testcase_19 AC 439 ms
114,404 KB
testcase_20 AC 433 ms
114,404 KB
testcase_21 AC 477 ms
114,304 KB
testcase_22 AC 475 ms
114,404 KB
testcase_23 AC 472 ms
114,404 KB
testcase_24 AC 455 ms
114,408 KB
testcase_25 AC 489 ms
114,408 KB
testcase_26 AC 445 ms
114,404 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, m, q = map(int, input().split())
a = list(map(int, input().split()))
for i in range(n):
	a[i] -= 1
mod = 998244353
sm = [0]
now = 1
pw = [now]
for i in a[::-1]:
	sm.append(sm[-1] + i * now)
	now = now * m % mod
	pw.append(now)
sm = sm[::-1]
for _ in range(q):
	l, r = map(int, input().split())
	l -= 1
	print((1 + (sm[l] - sm[r]) * pow(pw[n - r], mod - 2, mod)) % mod)
0