結果
| 問題 |
No.1066 #いろいろな色 / Red and Blue and more various colors (Easy)
|
| コンテスト | |
| ユーザー |
htensai
|
| 提出日時 | 2020-06-04 13:03:42 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 433 ms / 2,000 ms |
| コード長 | 719 bytes |
| コンパイル時間 | 3,190 ms |
| コンパイル使用メモリ | 77,252 KB |
| 実行使用メモリ | 58,860 KB |
| 最終ジャッジ日時 | 2024-11-28 16:40:18 |
| 合計ジャッジ時間 | 10,855 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 24 |
ソースコード
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();
}
long[] dp = new long[n + 1];
dp[0] = 1;
for (int i = 1; i <= n; i++) {
for (int j = i; j >= 1; j--) {
dp[j] = dp[j] * (arr[i] - 1) + dp[j - 1];
dp[j] %= MOD;
}
dp[0] = dp[0] * (arr[i] - 1);
dp[0] %= MOD;
}
StringBuilder sb = new StringBuilder();
for (int i = 0; i < q; i++) {
sb.append(dp[sc.nextInt()]).append("\n");
}
System.out.print(sb);
}
}
htensai