結果

問題 No.2144 MM
ユーザー とりゐとりゐ
提出日時 2022-12-03 01:27:01
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 80 ms / 2,000 ms
コード長 250 bytes
コンパイル時間 276 ms
コンパイル使用メモリ 82,476 KB
実行使用メモリ 104,904 KB
最終ジャッジ日時 2024-04-18 10:44:35
合計ジャッジ時間 3,384 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
52,108 KB
testcase_01 AC 32 ms
52,108 KB
testcase_02 AC 35 ms
51,752 KB
testcase_03 AC 33 ms
52,168 KB
testcase_04 AC 33 ms
53,296 KB
testcase_05 AC 35 ms
53,280 KB
testcase_06 AC 33 ms
53,064 KB
testcase_07 AC 80 ms
103,928 KB
testcase_08 AC 77 ms
104,056 KB
testcase_09 AC 73 ms
104,248 KB
testcase_10 AC 76 ms
104,904 KB
testcase_11 AC 75 ms
104,272 KB
testcase_12 AC 78 ms
103,352 KB
testcase_13 AC 77 ms
103,016 KB
testcase_14 AC 74 ms
103,440 KB
testcase_15 AC 71 ms
97,636 KB
testcase_16 AC 45 ms
70,304 KB
testcase_17 AC 64 ms
92,956 KB
testcase_18 AC 46 ms
72,064 KB
testcase_19 AC 70 ms
93,784 KB
testcase_20 AC 69 ms
91,024 KB
testcase_21 AC 55 ms
81,876 KB
testcase_22 AC 45 ms
64,296 KB
testcase_23 AC 69 ms
90,900 KB
testcase_24 AC 45 ms
68,344 KB
testcase_25 AC 36 ms
53,168 KB
testcase_26 AC 35 ms
52,132 KB
testcase_27 AC 34 ms
53,136 KB
testcase_28 AC 31 ms
53,620 KB
testcase_29 AC 33 ms
52,836 KB
testcase_30 AC 36 ms
52,620 KB
testcase_31 AC 35 ms
52,756 KB
testcase_32 AC 37 ms
52,276 KB
testcase_33 AC 35 ms
53,416 KB
testcase_34 AC 34 ms
52,988 KB
testcase_35 AC 36 ms
53,004 KB
testcase_36 AC 35 ms
51,872 KB
testcase_37 AC 32 ms
52,068 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod=998244353
n,m=map(int,input().split())
a=list(map(int,input().split()))
res=0
sgn=1
for i in a:
  res+=sgn*i
  sgn=-sgn
if res%m!=0:
  print(-1)
  exit()

mod=998244353
N=0
for i in a:
  N*=(m-1)
  N+=i
  N%=mod

print((N*pow(m,mod-2,mod)+1)%mod)
0