結果
問題 | No.1066 #いろいろな色 / Red and Blue and more various colors (Easy) |
ユーザー | tenten |
提出日時 | 2021-11-05 12:55:58 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 309 ms / 2,000 ms |
コード長 | 1,669 bytes |
コンパイル時間 | 1,994 ms |
コンパイル使用メモリ | 77,472 KB |
実行使用メモリ | 45,728 KB |
最終ジャッジ日時 | 2024-04-23 20:22:55 |
合計ジャッジ時間 | 6,082 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 53 ms
37,136 KB |
testcase_01 | AC | 53 ms
37,128 KB |
testcase_02 | AC | 51 ms
36,628 KB |
testcase_03 | AC | 49 ms
36,648 KB |
testcase_04 | AC | 48 ms
37,072 KB |
testcase_05 | AC | 48 ms
36,924 KB |
testcase_06 | AC | 48 ms
37,272 KB |
testcase_07 | AC | 50 ms
37,120 KB |
testcase_08 | AC | 187 ms
45,236 KB |
testcase_09 | AC | 54 ms
37,084 KB |
testcase_10 | AC | 302 ms
45,448 KB |
testcase_11 | AC | 124 ms
43,040 KB |
testcase_12 | AC | 120 ms
42,772 KB |
testcase_13 | AC | 126 ms
43,200 KB |
testcase_14 | AC | 159 ms
44,576 KB |
testcase_15 | AC | 210 ms
45,340 KB |
testcase_16 | AC | 103 ms
43,032 KB |
testcase_17 | AC | 123 ms
43,028 KB |
testcase_18 | AC | 202 ms
45,252 KB |
testcase_19 | AC | 129 ms
43,028 KB |
testcase_20 | AC | 53 ms
36,608 KB |
testcase_21 | AC | 197 ms
45,436 KB |
testcase_22 | AC | 53 ms
36,908 KB |
testcase_23 | AC | 52 ms
36,764 KB |
testcase_24 | AC | 48 ms
36,636 KB |
testcase_25 | AC | 309 ms
45,728 KB |
testcase_26 | AC | 294 ms
45,424 KB |
ソースコード
import java.io.*; import java.util.*; public class Main { static final int MOD = 998244353; public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); int n = sc.nextInt(); int q = sc.nextInt(); int[] current = new int[1]; current[0] = 1; for (int i = 0; i < n; i++) { int x = sc.nextInt(); int[] next = new int[i + 2]; for (int j = 0; j <= i; j++) { next[j] += (int)(current[j] * (long)(x - 1) % MOD); next[j] %= MOD; next[j + 1] += current[j]; next[j + 1] %= MOD; } current = next; } StringBuilder sb = new StringBuilder(); for (int i = 0; i < q; i++) { sb.append(current[sc.nextInt()]).append("\n"); } System.out.print(sb); } } class Scanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); public Scanner() throws Exception { } public int nextInt() throws Exception { return Integer.parseInt(next()); } public long nextLong() throws Exception { return Long.parseLong(next()); } public double nextDouble() throws Exception { return Double.parseDouble(next()); } public String nextLine() throws Exception { return br.readLine(); } public String next() throws Exception { if (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } return st.nextToken(); } }