結果

問題 No.1066 #いろいろな色 / Red and Blue and more various colors (Easy)
ユーザー tentententen
提出日時 2021-11-05 12:50:35
言語 Java21
(openjdk 21)
結果
MLE  
実行時間 -
コード長 1,609 bytes
コンパイル時間 1,831 ms
コンパイル使用メモリ 77,816 KB
実行使用メモリ 374,384 KB
最終ジャッジ日時 2024-04-23 20:16:31
合計ジャッジ時間 8,088 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 48 ms
37,200 KB
testcase_01 AC 47 ms
36,980 KB
testcase_02 AC 47 ms
37,296 KB
testcase_03 AC 46 ms
37,260 KB
testcase_04 AC 46 ms
36,984 KB
testcase_05 AC 48 ms
36,700 KB
testcase_06 AC 49 ms
37,028 KB
testcase_07 AC 50 ms
37,136 KB
testcase_08 MLE -
testcase_09 AC 49 ms
40,604 KB
testcase_10 MLE -
testcase_11 AC 206 ms
103,188 KB
testcase_12 AC 156 ms
82,832 KB
testcase_13 AC 244 ms
103,072 KB
testcase_14 AC 271 ms
106,616 KB
testcase_15 MLE -
testcase_16 AC 136 ms
68,472 KB
testcase_17 AC 155 ms
75,540 KB
testcase_18 MLE -
testcase_19 AC 174 ms
102,456 KB
testcase_20 AC 49 ms
37,040 KB
testcase_21 MLE -
testcase_22 AC 52 ms
41,000 KB
testcase_23 AC 52 ms
36,980 KB
testcase_24 AC 52 ms
37,264 KB
testcase_25 MLE -
testcase_26 MLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

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