結果

問題 No.1145 Sums of Powers
ユーザー gew1fw
提出日時 2025-06-12 19:06:12
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 605 bytes
コンパイル時間 191 ms
コンパイル使用メモリ 82,380 KB
実行使用メモリ 60,404 KB
最終ジャッジ日時 2025-06-12 19:07:00
合計ジャッジ時間 3,747 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 3 TLE * 1 -- * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

MOD = 998244353

def main():
    import sys
    input = sys.stdin.read().split()
    idx = 0
    N = int(input[idx])
    idx += 1
    M = int(input[idx])
    idx += 1
    A = list(map(int, input[idx:idx+N]))
    idx += N
    
    # Precompute S_k for each k from 1 to M
    S = [0] * (M + 1)
    for a in A:
        if a == 0:
            continue
        current = a
        S[1] = (S[1] + current) % MOD
        for k in range(2, M + 1):
            current = current * a % MOD
            S[k] = (S[k] + current) % MOD
    
    print(' '.join(map(str, S[1:M+1])))

if __name__ == '__main__':
    main()
0