結果

問題 No.1066 #いろいろな色 / Red and Blue and more various colors (Easy)
ユーザー tenten
提出日時 2020-08-20 11:22:16
言語 Java
(openjdk 23)
結果
AC  
実行時間 519 ms / 2,000 ms
コード長 688 bytes
コンパイル時間 2,104 ms
コンパイル使用メモリ 74,004 KB
実行使用メモリ 62,944 KB
最終ジャッジ日時 2024-10-13 05:03:59
合計ジャッジ時間 10,012 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 24
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    static final int MOD = 998244353;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int q = sc.nextInt();
        int[] dp = new int[n + 1];
        dp[0] = 1;
        for (int i = 1; i <= n; i++) {
            long x = sc.nextInt();
            for (int j = i - 1; j >= 0; j--) {
                dp[j + 1] += dp[j];
                dp[j + 1] %= MOD;
                dp[j] = (int)(dp[j] * (x - 1) % MOD);
                dp[j] %= MOD;
            }
        }
        for (int i = 0; i < q; i++) {
            System.out.println(dp[sc.nextInt()]);
        }
    }
} 
0