結果

問題 No.1066 #いろいろな色 / Red and Blue and more various colors (Easy)
ユーザー phsplsphspls
提出日時 2020-07-21 23:58:39
言語 Rust
(1.77.0)
結果
MLE  
実行時間 -
コード長 953 bytes
コンパイル時間 792 ms
コンパイル使用メモリ 145,780 KB
実行使用メモリ 283,632 KB
最終ジャッジ日時 2023-08-30 06:03:18
合計ジャッジ時間 5,403 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 138 ms
103,788 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 MLE -
testcase_11 AC 79 ms
58,880 KB
testcase_12 AC 61 ms
44,620 KB
testcase_13 AC 82 ms
60,796 KB
testcase_14 AC 87 ms
63,964 KB
testcase_15 MLE -
testcase_16 AC 34 ms
26,496 KB
testcase_17 AC 41 ms
30,716 KB
testcase_18 MLE -
testcase_19 AC 76 ms
56,572 KB
testcase_20 AC 1 ms
4,380 KB
testcase_21 AC 172 ms
126,820 KB
testcase_22 AC 1 ms
4,384 KB
testcase_23 AC 1 ms
4,376 KB
testcase_24 AC 1 ms
4,380 KB
testcase_25 MLE -
testcase_26 MLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

const DIVISOR: usize = 998244353;

//TODO
fn main() {
    let mut nq = String::new();
    std::io::stdin().read_line(&mut nq).ok();
    let nq: Vec<usize> = nq.trim().split_whitespace().map(|s| s.parse().unwrap()).collect();
    let n = nq[0];
    let mut a = String::new();
    std::io::stdin().read_line(&mut a).ok();
    let a: Vec<usize> = a.trim().split_whitespace().map(|s| s.parse().unwrap()).collect();

    let mut dp: Vec<Vec<usize>> = vec![vec![1; n+1]; n+1];
    for i in 1..=n {
        for j in i..=n {
            dp[i][j] = dp[i-1][j-1] * (a[j-1] - 1);
            dp[i][j] %= DIVISOR;
            if j > i {
                dp[i][j] += dp[i][j-1];
                dp[i][j] %= DIVISOR;
            }
        }
    }

    let mut b = String::new();
    std::io::stdin().read_line(&mut b).ok();
    b.trim().split_whitespace().map(|s| s.parse().unwrap())
        .for_each(|i: usize| {
            println!("{}", dp[n-i][n]);
        });
}
0