結果
問題 | No.1114 足し算盆に返らず |
ユーザー |
|
提出日時 | 2020-07-17 21:42:04 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 880 ms / 2,000 ms |
コード長 | 601 bytes |
コンパイル時間 | 16,241 ms |
コンパイル使用メモリ | 400,640 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-11-29 22:46:52 |
合計ジャッジ時間 | 43,376 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 26 |
ソースコード
fn main() {let mut n = String::new();std::io::stdin().read_line(&mut n).ok();let n: usize = n.trim().parse().unwrap();let mut dp: Vec<bool> = vec![false; n+1];let mut result: Vec<usize> = vec![];for i in 1..=n {if dp[i] { continue; }for p in result.iter() {if *p + i <= n {dp[*p+i] = true;}}dp[i] = true;if 2*i <= n {dp[2*i] = true;}result.push(i);}println!("{}", result.iter().map(|&i| i.to_string()).collect::<Vec<String>>().join(" "));}