結果

問題 No.1066 #いろいろな色 / Red and Blue and more various colors (Easy)
ユーザー htensaihtensai
提出日時 2020-06-04 12:59:35
言語 Java21
(openjdk 21)
結果
MLE  
実行時間 -
コード長 783 bytes
コンパイル時間 1,880 ms
コンパイル使用メモリ 77,640 KB
実行使用メモリ 216,220 KB
最終ジャッジ日時 2024-05-06 10:26:43
合計ジャッジ時間 10,127 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 101 ms
39,760 KB
testcase_01 AC 106 ms
40,004 KB
testcase_02 AC 107 ms
40,056 KB
testcase_03 AC 95 ms
39,304 KB
testcase_04 AC 108 ms
40,984 KB
testcase_05 AC 109 ms
40,292 KB
testcase_06 AC 113 ms
41,072 KB
testcase_07 AC 101 ms
40,004 KB
testcase_08 AC 396 ms
108,140 KB
testcase_09 AC 124 ms
41,452 KB
testcase_10 MLE -
testcase_11 AC 326 ms
81,376 KB
testcase_12 AC 301 ms
71,172 KB
testcase_13 AC 360 ms
82,504 KB
testcase_14 AC 326 ms
82,228 KB
testcase_15 MLE -
testcase_16 AC 245 ms
55,900 KB
testcase_17 AC 275 ms
63,248 KB
testcase_18 MLE -
testcase_19 AC 361 ms
80,888 KB
testcase_20 AC 127 ms
41,324 KB
testcase_21 AC 441 ms
126,328 KB
testcase_22 AC 121 ms
41,124 KB
testcase_23 AC 113 ms
41,328 KB
testcase_24 AC 111 ms
40,956 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