結果

問題 No.634 硬貨の枚数1
ユーザー phsplsphspls
提出日時 2022-12-31 16:09:10
言語 Rust
(1.77.0)
結果
TLE  
実行時間 -
コード長 914 bytes
コンパイル時間 1,413 ms
コンパイル使用メモリ 146,544 KB
実行使用メモリ 88,764 KB
最終ジャッジ日時 2023-08-17 16:18:15
合計ジャッジ時間 14,043 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 16 ms
7,148 KB
testcase_15 AC 775 ms
74,796 KB
testcase_16 AC 88 ms
27,380 KB
testcase_17 AC 84 ms
28,536 KB
testcase_18 AC 43 ms
17,620 KB
testcase_19 AC 37 ms
18,696 KB
testcase_20 AC 68 ms
26,872 KB
testcase_21 AC 791 ms
83,824 KB
testcase_22 AC 190 ms
47,792 KB
testcase_23 AC 112 ms
29,352 KB
testcase_24 AC 1 ms
4,380 KB
testcase_25 AC 1 ms
4,376 KB
testcase_26 AC 1 ms
4,376 KB
testcase_27 AC 1 ms
4,376 KB
testcase_28 AC 1 ms
4,380 KB
testcase_29 AC 1 ms
4,376 KB
testcase_30 AC 1 ms
4,380 KB
testcase_31 AC 1 ms
4,380 KB
testcase_32 AC 1 ms
4,376 KB
testcase_33 AC 1 ms
4,380 KB
testcase_34 AC 10 ms
5,172 KB
testcase_35 AC 44 ms
16,968 KB
testcase_36 AC 130 ms
37,684 KB
testcase_37 AC 55 ms
20,688 KB
testcase_38 AC 24 ms
9,424 KB
testcase_39 AC 641 ms
73,424 KB
testcase_40 AC 237 ms
47,888 KB
testcase_41 AC 154 ms
39,952 KB
testcase_42 AC 189 ms
46,404 KB
testcase_43 AC 77 ms
23,828 KB
testcase_44 AC 1 ms
4,380 KB
testcase_45 AC 2 ms
4,380 KB
testcase_46 AC 11 ms
5,848 KB
testcase_47 AC 140 ms
38,372 KB
testcase_48 AC 1 ms
4,380 KB
testcase_49 AC 5 ms
4,376 KB
testcase_50 AC 311 ms
63,524 KB
testcase_51 AC 54 ms
10,744 KB
testcase_52 AC 1 ms
4,376 KB
testcase_53 AC 1 ms
4,380 KB
testcase_54 AC 1 ms
4,376 KB
testcase_55 TLE -
testcase_56 TLE -
testcase_57 TLE -
testcase_58 TLE -
testcase_59 TLE -
testcase_60 TLE -
testcase_61 TLE -
testcase_62 TLE -
testcase_63 TLE -
testcase_64 TLE -
testcase_65 TLE -
testcase_66 TLE -
testcase_67 TLE -
testcase_68 TLE -
testcase_69 TLE -
testcase_70 TLE -
testcase_71 TLE -
testcase_72 TLE -
testcase_73 TLE -
testcase_74 TLE -
testcase_75 TLE -
testcase_76 AC 1 ms
4,376 KB
testcase_77 AC 4 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

use std::collections::VecDeque;


fn main() {
    let mut n = String::new();
    std::io::stdin().read_line(&mut n).ok();
    let n: usize = n.trim().parse().unwrap();

    let mut deque = VecDeque::new();
    let mut checked = vec![false; n+1];
    checked[n] = true;
    deque.push_back(n);
    let mut cnt = 0usize;
    loop {
        cnt += 1;
        let limit = deque.len();
        for _ in 0..limit {
            let val = deque.pop_front().unwrap();
            for i in 1.. {
                let minus_val = i * (i+1) / 2;
                if minus_val > val { break; }
                if minus_val == val {
                    println!("{}", cnt);
                    return;
                }
                let val = val - minus_val;
                if !checked[val] {
                    deque.push_back(val);
                    checked[val] = true;
                }
            }
        }
    }
}
0