結果

問題 No.1114 足し算盆に返らず
ユーザー phsplsphspls
提出日時 2020-07-17 21:42:04
言語 Rust
(1.77.0)
結果
AC  
実行時間 778 ms / 2,000 ms
コード長 601 bytes
コンパイル時間 16,201 ms
コンパイル使用メモリ 384,524 KB
実行使用メモリ 5,504 KB
最終ジャッジ日時 2024-05-07 07:43:27
合計ジャッジ時間 35,046 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 770 ms
5,376 KB
testcase_01 AC 778 ms
5,376 KB
testcase_02 AC 769 ms
5,376 KB
testcase_03 AC 464 ms
5,376 KB
testcase_04 AC 683 ms
5,376 KB
testcase_05 AC 199 ms
5,376 KB
testcase_06 AC 711 ms
5,376 KB
testcase_07 AC 699 ms
5,376 KB
testcase_08 AC 270 ms
5,376 KB
testcase_09 AC 194 ms
5,376 KB
testcase_10 AC 268 ms
5,376 KB
testcase_11 AC 5 ms
5,376 KB
testcase_12 AC 377 ms
5,376 KB
testcase_13 AC 770 ms
5,376 KB
testcase_14 AC 19 ms
5,376 KB
testcase_15 AC 130 ms
5,376 KB
testcase_16 AC 229 ms
5,376 KB
testcase_17 AC 387 ms
5,376 KB
testcase_18 AC 74 ms
5,376 KB
testcase_19 AC 145 ms
5,376 KB
testcase_20 AC 759 ms
5,504 KB
testcase_21 AC 124 ms
5,376 KB
testcase_22 AC 1 ms
5,376 KB
testcase_23 AC 1 ms
5,376 KB
testcase_24 AC 1 ms
5,376 KB
testcase_25 AC 1 ms
5,376 KB
testcase_26 AC 1 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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(" "));
}
0