結果

問題 No.1066 #いろいろな色 / Red and Blue and more various colors (Easy)
ユーザー tentententen
提出日時 2020-08-20 11:22:16
言語 Java21
(openjdk 21)
結果
AC  
実行時間 506 ms / 2,000 ms
コード長 688 bytes
コンパイル時間 2,096 ms
コンパイル使用メモリ 74,640 KB
実行使用メモリ 52,188 KB
最終ジャッジ日時 2024-04-21 06:24:27
合計ジャッジ時間 9,875 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 106 ms
40,120 KB
testcase_01 AC 124 ms
41,172 KB
testcase_02 AC 122 ms
41,384 KB
testcase_03 AC 111 ms
40,436 KB
testcase_04 AC 106 ms
39,960 KB
testcase_05 AC 113 ms
40,488 KB
testcase_06 AC 110 ms
39,764 KB
testcase_07 AC 121 ms
41,544 KB
testcase_08 AC 382 ms
47,532 KB
testcase_09 AC 147 ms
41,432 KB
testcase_10 AC 506 ms
48,448 KB
testcase_11 AC 345 ms
48,032 KB
testcase_12 AC 320 ms
47,512 KB
testcase_13 AC 338 ms
47,096 KB
testcase_14 AC 338 ms
47,864 KB
testcase_15 AC 437 ms
48,204 KB
testcase_16 AC 272 ms
46,160 KB
testcase_17 AC 288 ms
46,264 KB
testcase_18 AC 424 ms
48,612 KB
testcase_19 AC 332 ms
48,120 KB
testcase_20 AC 142 ms
41,696 KB
testcase_21 AC 413 ms
47,932 KB
testcase_22 AC 133 ms
41,476 KB
testcase_23 AC 120 ms
40,912 KB
testcase_24 AC 118 ms
41,264 KB
testcase_25 AC 505 ms
52,188 KB
testcase_26 AC 500 ms
48,140 KB
権限があれば一括ダウンロードができます

ソースコード

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