結果

問題 No.1066 #いろいろな色 / Red and Blue and more various colors (Easy)
ユーザー lam6er
提出日時 2025-04-15 22:15:49
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 560 bytes
コンパイル時間 752 ms
コンパイル使用メモリ 81,596 KB
実行使用メモリ 65,304 KB
最終ジャッジ日時 2025-04-15 22:18:06
合計ジャッジ時間 3,277 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 3
other WA * 24
権限があれば一括ダウンロードができます

ソースコード

diff #

MOD = 998244353

def main():
    import sys
    input = sys.stdin.read().split()
    ptr = 0
    N, Q = int(input[ptr]), int(input[ptr+1])
    ptr +=2
    A = list(map(int, input[ptr:ptr+N]))
    ptr +=N
    B = list(map(int, input[ptr:ptr+Q]))
    
    dp = [0]*(N+1)
    dp[0] = 1
    for a in A:
        for j in range(N, 0, -1):
            dp[j] = (dp[j] * (a-1) + dp[j-1]) % MOD
        dp[0] = dp[0] * (a-1) % MOD
    
    res = []
    for b in B:
        res.append(dp[b] % MOD)
    print(' '.join(map(str, res)))

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