結果

問題 No.1145 Sums of Powers
ユーザー lam6er
提出日時 2025-03-31 17:38:40
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 697 bytes
コンパイル時間 272 ms
コンパイル使用メモリ 82,836 KB
実行使用メモリ 64,260 KB
最終ジャッジ日時 2025-03-31 17:39:44
合計ジャッジ時間 4,098 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 3 TLE * 1 -- * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
MOD = 998244353

def main():
    input = sys.stdin.read().split()
    idx = 0
    N, M = int(input[idx]), int(input[idx+1])
    idx += 2
    A = list(map(int, input[idx:idx+N]))
    
    from collections import defaultdict
    cnt = defaultdict(int)
    for a in A:
        if a != 0:  # Skip zeros since they contribute nothing
            cnt[a] += 1
    
    result = [0] * (M + 1)
    for v in cnt:
        c = cnt[v]
        current = v
        for k in range(1, M + 1):
            result[k] = (result[k] + current * c) % MOD
            if k < M:
                current = current * v % MOD
    
    print(' '.join(map(str, result[1:M+1])))

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