結果

問題 No.47 ポケットを叩くとビスケットが2倍
ユーザー iwot
提出日時 2019-04-26 13:40:02
言語 Rust
(1.83.0 + proconio)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 441 bytes
コンパイル時間 14,866 ms
コンパイル使用メモリ 377,324 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-24 06:14:31
合計ジャッジ時間 16,243 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

fn main() {
    let mut input = String::new();
    let _ = std::io::stdin().read_line(&mut input);
    let max: i32 = input.trim().parse().unwrap();

    fn pocket(x: i32, count: i32) -> i32 {
        if x % 2 == 0 {
            pocket(x / 2, count + 1)
        } else if x == 1 {
            count
        } else {
            pocket(x / 2 + x % 2, count + 1)
        }
    }

    let result = pocket(max, 0);
    println!("{}", result);
}
0