結果

問題 No.1066 #いろいろな色 / Red and Blue and more various colors (Easy)
ユーザー phspls
提出日時 2020-07-21 23:58:39
言語 Rust
(1.83.0 + proconio)
結果
MLE  
実行時間 -
コード長 953 bytes
コンパイル時間 12,191 ms
コンパイル使用メモリ 399,012 KB
実行使用メモリ 283,648 KB
最終ジャッジ日時 2024-12-31 17:45:07
合計ジャッジ時間 15,782 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 19 MLE * 5
権限があれば一括ダウンロードができます

ソースコード

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