結果

問題 No.2144 MM
ユーザー first_vilfirst_vil
提出日時 2022-11-07 12:41:50
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 118 ms / 2,000 ms
コード長 269 bytes
コンパイル時間 1,384 ms
コンパイル使用メモリ 86,916 KB
実行使用メモリ 108,960 KB
最終ジャッジ日時 2023-09-28 02:17:52
合計ジャッジ時間 8,355 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 65 ms
70,976 KB
testcase_01 AC 67 ms
71,104 KB
testcase_02 AC 66 ms
71,240 KB
testcase_03 AC 67 ms
71,308 KB
testcase_04 AC 68 ms
70,820 KB
testcase_05 AC 67 ms
71,332 KB
testcase_06 AC 67 ms
71,076 KB
testcase_07 AC 113 ms
108,284 KB
testcase_08 AC 114 ms
108,880 KB
testcase_09 AC 113 ms
108,584 KB
testcase_10 AC 113 ms
108,960 KB
testcase_11 AC 113 ms
108,608 KB
testcase_12 AC 113 ms
108,556 KB
testcase_13 AC 118 ms
108,348 KB
testcase_14 AC 113 ms
108,668 KB
testcase_15 AC 108 ms
104,384 KB
testcase_16 AC 80 ms
82,056 KB
testcase_17 AC 107 ms
100,820 KB
testcase_18 AC 82 ms
84,396 KB
testcase_19 AC 104 ms
101,260 KB
testcase_20 AC 100 ms
98,044 KB
testcase_21 AC 91 ms
91,164 KB
testcase_22 AC 76 ms
77,540 KB
testcase_23 AC 102 ms
98,480 KB
testcase_24 AC 78 ms
80,608 KB
testcase_25 AC 67 ms
70,900 KB
testcase_26 AC 68 ms
71,276 KB
testcase_27 AC 67 ms
71,400 KB
testcase_28 AC 66 ms
71,132 KB
testcase_29 AC 68 ms
71,100 KB
testcase_30 AC 68 ms
71,392 KB
testcase_31 AC 67 ms
71,216 KB
testcase_32 AC 65 ms
71,380 KB
testcase_33 AC 64 ms
71,160 KB
testcase_34 AC 65 ms
71,016 KB
testcase_35 AC 67 ms
71,120 KB
testcase_36 AC 65 ms
71,364 KB
testcase_37 AC 67 ms
71,152 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n,m=map(int,input().split())
p=list(map(int,input().split()))

#check
q=p[:]
for i in range(n-1):
    q[i+1]+=m-q[i]%m
if q[-1]%m:
    print(-1)
    exit(0)

mod=998244353
ans=0
for i in range(n):
    ans=(ans*(m-1)+p[i])%mod
ans=(ans*pow(m,mod-2,mod)+1)%mod
print(ans)
0