結果

問題 No.2144 MM
ユーザー titiatitia
提出日時 2023-05-03 03:27:57
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,767 ms / 2,000 ms
コード長 328 bytes
コンパイル時間 79 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 30,580 KB
最終ジャッジ日時 2024-05-01 09:36:01
合計ジャッジ時間 21,986 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
10,880 KB
testcase_01 AC 28 ms
10,880 KB
testcase_02 AC 28 ms
10,880 KB
testcase_03 AC 28 ms
10,752 KB
testcase_04 AC 28 ms
10,880 KB
testcase_05 AC 29 ms
10,752 KB
testcase_06 AC 29 ms
10,752 KB
testcase_07 AC 148 ms
29,552 KB
testcase_08 AC 1,721 ms
29,552 KB
testcase_09 AC 153 ms
29,556 KB
testcase_10 AC 1,767 ms
29,556 KB
testcase_11 AC 1,724 ms
29,552 KB
testcase_12 AC 1,730 ms
29,552 KB
testcase_13 AC 1,721 ms
30,580 KB
testcase_14 AC 1,711 ms
29,556 KB
testcase_15 AC 1,444 ms
26,316 KB
testcase_16 AC 407 ms
15,280 KB
testcase_17 AC 1,339 ms
25,952 KB
testcase_18 AC 66 ms
16,192 KB
testcase_19 AC 1,350 ms
26,556 KB
testcase_20 AC 1,159 ms
23,448 KB
testcase_21 AC 830 ms
20,492 KB
testcase_22 AC 207 ms
12,800 KB
testcase_23 AC 1,216 ms
23,988 KB
testcase_24 AC 356 ms
14,448 KB
testcase_25 AC 31 ms
10,880 KB
testcase_26 AC 30 ms
10,752 KB
testcase_27 AC 30 ms
10,752 KB
testcase_28 AC 34 ms
10,752 KB
testcase_29 AC 32 ms
10,880 KB
testcase_30 AC 36 ms
10,880 KB
testcase_31 AC 32 ms
10,752 KB
testcase_32 AC 37 ms
10,752 KB
testcase_33 AC 31 ms
10,752 KB
testcase_34 AC 30 ms
10,880 KB
testcase_35 AC 30 ms
10,752 KB
testcase_36 AC 31 ms
10,752 KB
testcase_37 AC 30 ms
10,752 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,M=map(int,input().split())
A=list(map(int,input().split()))

score=0

for i in range(N):
    if i%2==0:
        score+=A[i]
    else:
        score-=A[i]

if score%M!=0:
    print(-1)
    exit()

mod=998244353
ANS=0

for i in range(N):
    k=N-1-i
    ANS+=A[k]*pow(M-1,i,mod)*pow(M,mod-2,mod)
    ANS%=mod

print((ANS+1)%mod)
0