結果

問題 No.2966 Simple Plus Minus Problem
ユーザー hato336
提出日時 2024-11-16 16:38:14
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,144 bytes
コンパイル時間 881 ms
コンパイル使用メモリ 81,980 KB
実行使用メモリ 252,228 KB
最終ジャッジ日時 2024-11-16 16:38:32
合計ジャッジ時間 17,657 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 6 WA * 48
権限があれば一括ダウンロードができます

ソースコード

diff #

n,k = map(int,input().split())
a = list(map(int,input().split()))
aa = a[:]
c = [a[:]]
import itertools
for i in range(10):
    b = [a[j] if j % 2 == 0 else -a[j] for j in range(n)]
    a = list(itertools.accumulate(b))
    c.append(a)
    #print(*a)
a = aa[:]
mod = 998244353
ans = []
for i in range(n):
    if i % 2 == 0:
        x = c[1][i] - c[0][i]
        y = c[3][i] - c[2][i]
        cnt = (k//2) + (k % 2)
        d = y-x
        res = x * cnt + d * ((1+cnt-1)*(cnt-1)//2)

        x = c[2][i] - c[1][i]
        y = c[4][i] - c[3][i]
        cnt = (k//2)
        d = -abs(y-x)
        res += (x * cnt + d * ((1+cnt-1)*(cnt-1)//2) + a[i]) % mod
        ans.append(res%mod)
        
    else:
        x = c[1][i] - c[0][i]
        y = c[3][i] - c[2][i]
        cnt = (k//2) + (k % 2)
        d = -abs(y-x)

        res = x * cnt + d * ((1+cnt-1)*(cnt-1)//2)

        x = c[2][i] - c[1][i]
        y = c[4][i] - c[3][i]
        cnt = (k//2)
        d = abs(y-x)

        res += (x * cnt + d * ((1+cnt-1)*(cnt-1)//2) + a[i]) % mod
        ans.append(res%mod)
        
print(*ans)
-20
20
-20
20



-6
8
-9
11
-12
14


6
-3
8
-4
10
-5
12
-6
0