結果

問題 No.2144 MM
ユーザー 👑 KazunKazun
提出日時 2022-12-03 00:13:08
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 84 ms / 2,000 ms
コード長 391 bytes
コンパイル時間 280 ms
コンパイル使用メモリ 82,560 KB
実行使用メモリ 103,680 KB
最終ジャッジ日時 2024-04-18 09:21:12
合計ジャッジ時間 3,535 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
51,584 KB
testcase_01 AC 34 ms
51,712 KB
testcase_02 AC 32 ms
51,712 KB
testcase_03 AC 39 ms
51,968 KB
testcase_04 AC 34 ms
51,968 KB
testcase_05 AC 38 ms
51,712 KB
testcase_06 AC 38 ms
51,584 KB
testcase_07 AC 78 ms
102,912 KB
testcase_08 AC 80 ms
102,912 KB
testcase_09 AC 77 ms
102,656 KB
testcase_10 AC 84 ms
103,680 KB
testcase_11 AC 80 ms
103,040 KB
testcase_12 AC 81 ms
102,912 KB
testcase_13 AC 82 ms
102,016 KB
testcase_14 AC 83 ms
103,296 KB
testcase_15 AC 74 ms
97,536 KB
testcase_16 AC 51 ms
69,888 KB
testcase_17 AC 73 ms
92,672 KB
testcase_18 AC 50 ms
72,320 KB
testcase_19 AC 77 ms
92,928 KB
testcase_20 AC 72 ms
89,728 KB
testcase_21 AC 60 ms
81,024 KB
testcase_22 AC 42 ms
64,000 KB
testcase_23 AC 70 ms
90,240 KB
testcase_24 AC 52 ms
67,968 KB
testcase_25 AC 38 ms
52,352 KB
testcase_26 AC 35 ms
52,096 KB
testcase_27 AC 38 ms
51,584 KB
testcase_28 AC 38 ms
51,840 KB
testcase_29 AC 34 ms
52,096 KB
testcase_30 AC 39 ms
52,608 KB
testcase_31 AC 35 ms
52,096 KB
testcase_32 AC 35 ms
52,224 KB
testcase_33 AC 33 ms
51,712 KB
testcase_34 AC 38 ms
51,840 KB
testcase_35 AC 34 ms
51,840 KB
testcase_36 AC 37 ms
51,968 KB
testcase_37 AC 34 ms
52,240 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

    # いい数列かの確認
    S=0
    for i in range(N):
        S+=(1 if i%2==0 else -1)*A[i]

    if S%M:
        return -1

    Mod=998244353
    X=0
    for a in A:
        X=((M-1)*X+a)%Mod

    return (X*pow(M,Mod-2,Mod)+1)%Mod

#==================================================
print(solve())
0