結果
問題 |
No.1066 #いろいろな色 / Red and Blue and more various colors (Easy)
|
ユーザー |
|
提出日時 | 2020-07-22 00:08:15 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 123 ms / 2,000 ms |
コード長 | 1,045 bytes |
コンパイル時間 | 11,731 ms |
コンパイル使用メモリ | 401,620 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-12-31 18:16:46 |
合計ジャッジ時間 | 14,077 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 24 |
ソースコード
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]); }); }