結果

問題 No.2144 MM
ユーザー sotanishysotanishy
提出日時 2022-12-02 23:29:52
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 187 ms / 2,000 ms
コード長 342 bytes
コンパイル時間 143 ms
コンパイル使用メモリ 82,356 KB
実行使用メモリ 105,044 KB
最終ジャッジ日時 2024-04-18 08:44:10
合計ジャッジ時間 4,624 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
52,224 KB
testcase_01 AC 35 ms
51,968 KB
testcase_02 AC 38 ms
52,224 KB
testcase_03 AC 38 ms
51,840 KB
testcase_04 AC 36 ms
51,712 KB
testcase_05 AC 34 ms
51,968 KB
testcase_06 AC 39 ms
51,712 KB
testcase_07 AC 99 ms
104,828 KB
testcase_08 AC 187 ms
105,044 KB
testcase_09 AC 99 ms
105,020 KB
testcase_10 AC 184 ms
104,912 KB
testcase_11 AC 186 ms
104,816 KB
testcase_12 AC 187 ms
104,960 KB
testcase_13 AC 185 ms
104,764 KB
testcase_14 AC 185 ms
104,832 KB
testcase_15 AC 161 ms
100,992 KB
testcase_16 AC 71 ms
71,680 KB
testcase_17 AC 152 ms
97,664 KB
testcase_18 AC 56 ms
73,856 KB
testcase_19 AC 156 ms
97,984 KB
testcase_20 AC 138 ms
94,148 KB
testcase_21 AC 109 ms
84,736 KB
testcase_22 AC 55 ms
65,536 KB
testcase_23 AC 142 ms
95,792 KB
testcase_24 AC 68 ms
69,888 KB
testcase_25 AC 35 ms
51,712 KB
testcase_26 AC 35 ms
51,840 KB
testcase_27 AC 36 ms
52,068 KB
testcase_28 AC 36 ms
52,352 KB
testcase_29 AC 38 ms
52,224 KB
testcase_30 AC 40 ms
52,864 KB
testcase_31 AC 37 ms
51,712 KB
testcase_32 AC 41 ms
52,736 KB
testcase_33 AC 35 ms
52,224 KB
testcase_34 AC 37 ms
51,712 KB
testcase_35 AC 36 ms
52,480 KB
testcase_36 AC 35 ms
51,712 KB
testcase_37 AC 35 ms
52,096 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

mod = 998244353
N, M = map(int, input().split())
A = list(map(int, input().split()))
s = sum((-1)**i*x for i, x in enumerate(A)) % M
if s != 0:
    print(-1)
    exit()
ans = 0
for i, x in enumerate(A):
    ans = (ans + x*pow(M-1, N-i-1, mod)) % mod
ans = (ans * pow(M, mod-2, mod) + 1) % mod
print(ans)
0