結果

問題 No.1869 Doubling?
ユーザー phspls
提出日時 2022-09-25 15:48:07
言語 Rust
(1.83.0 + proconio)
結果
WA  
実行時間 -
コード長 559 bytes
コンパイル時間 12,235 ms
コンパイル使用メモリ 406,312 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-12-22 12:59:41
合計ジャッジ時間 13,799 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 34 WA * 9
権限があれば一括ダウンロードができます

ソースコード

diff #

fn main() {
    let mut nm = String::new();
    std::io::stdin().read_line(&mut nm).ok();
    let nm: Vec<usize> = nm.trim().split_whitespace().map(|s| s.parse().unwrap()).collect();
    let n = nm[0];
    let m = nm[1];

    let mut start = m;
    let mut stack = vec![];
    while stack.len() < n && start > 1 {
        stack.push(start);
        if start & 1 == 1 {
            start = (start+1)/2;
        } else {
            start /= 2;
        }
    }
    let result = stack.iter().sum::<usize>() + (n - stack.len()) * 1;
    println!("{}", result);
}
0