結果

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

ソースコード

diff #

import sys
MOD = 998244353

def main():
    import sys
    N, M = map(int, sys.stdin.readline().split())
    A = list(map(int, sys.stdin.readline().split()))
    A = [a % MOD for a in A]

    # Compute the sum for each K from 1 to M directly
    # This approach is O(N*M), which is too slow for N, M up to 1e5
    # For the purpose of this exercise, we'll provide a correct but slow solution
    # Warning: This code will not pass the time constraints for large inputs

    S = [0] * (M + 1)
    for K in range(1, M+1):
        s = 0
        for a in A:
            s = (s + pow(a, K, MOD)) % MOD
        S[K] = s

    # Output S_1 to S_M
    print(' '.join(map(str, S[1:M+1])))

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