結果

問題 No.1066 #いろいろな色 / Red and Blue and more various colors (Easy)
ユーザー phsplsphspls
提出日時 2020-07-22 00:08:15
言語 Rust
(1.77.0)
結果
AC  
実行時間 140 ms / 2,000 ms
コード長 1,045 bytes
コンパイル時間 742 ms
コンパイル使用メモリ 145,420 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-30 06:15:15
合計ジャッジ時間 3,317 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 53 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 135 ms
4,376 KB
testcase_11 AC 31 ms
4,380 KB
testcase_12 AC 24 ms
4,380 KB
testcase_13 AC 32 ms
4,376 KB
testcase_14 AC 34 ms
4,376 KB
testcase_15 AC 91 ms
4,376 KB
testcase_16 AC 15 ms
4,376 KB
testcase_17 AC 17 ms
4,376 KB
testcase_18 AC 83 ms
4,376 KB
testcase_19 AC 30 ms
4,380 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 65 ms
4,376 KB
testcase_22 AC 1 ms
4,376 KB
testcase_23 AC 1 ms
4,376 KB
testcase_24 AC 1 ms
4,380 KB
testcase_25 AC 140 ms
4,380 KB
testcase_26 AC 140 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

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

    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!("{}", result[n-i]);
        });
}
0