結果

問題 No.1066 #いろいろな色 / Red and Blue and more various colors (Easy)
ユーザー htensaihtensai
提出日時 2020-06-04 12:59:35
言語 Java21
(openjdk 21)
結果
MLE  
実行時間 -
コード長 783 bytes
コンパイル時間 2,160 ms
コンパイル使用メモリ 74,576 KB
実行使用メモリ 223,652 KB
最終ジャッジ日時 2023-08-19 03:19:15
合計ジャッジ時間 11,756 ms
ジャッジサーバーID
(参考情報)
judge13 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 123 ms
55,288 KB
testcase_01 AC 127 ms
55,824 KB
testcase_02 AC 126 ms
53,796 KB
testcase_03 AC 126 ms
55,732 KB
testcase_04 AC 124 ms
55,764 KB
testcase_05 AC 122 ms
55,908 KB
testcase_06 AC 124 ms
55,880 KB
testcase_07 AC 122 ms
55,268 KB
testcase_08 AC 416 ms
122,940 KB
testcase_09 AC 143 ms
55,744 KB
testcase_10 MLE -
testcase_11 AC 381 ms
93,308 KB
testcase_12 AC 306 ms
85,156 KB
testcase_13 AC 388 ms
94,384 KB
testcase_14 AC 391 ms
93,496 KB
testcase_15 MLE -
testcase_16 AC 290 ms
67,840 KB
testcase_17 AC 296 ms
75,612 KB
testcase_18 MLE -
testcase_19 AC 341 ms
91,732 KB
testcase_20 AC 137 ms
55,732 KB
testcase_21 MLE -
testcase_22 AC 141 ms
55,832 KB
testcase_23 AC 124 ms
55,760 KB
testcase_24 AC 123 ms
55,952 KB
testcase_25 MLE -
testcase_26 MLE -
権限があれば一括ダウンロードができます

ソースコード

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[] arr = new int[n + 1];
		for (int i = 1; i <= n; i++) {
		    arr[i] = sc.nextInt();
		}
		int[][] dp = new int[n + 1][n + 1];
		dp[0][0] = 1;
		for (int i = 1; i <= n; i++) {
		    dp[i][0] = (int)(((long)dp[i - 1][0] * (arr[i] - 1)) % MOD);
		    for (int j = 1; j <= i; j++) {
		        dp[i][j] = (int)(((long)dp[i - 1][j] * (arr[i] - 1)) % MOD) + dp[i - 1][j - 1];
		        dp[i][j] %= MOD;
		    }
		}
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < q; i++) {
		    sb.append(dp[n][sc.nextInt()]).append("\n");
		}
		System.out.print(sb);
	}
}
0