結果

問題 No.642 Two Operations No.1
コンテスト
ユーザー taotao54321
提出日時 2018-10-08 13:20:39
言語 Rust
(1.97.1 + proconio + num + itertools + ACL)
コンパイル:
/usr/bin/rustc_custom
実行:
./target/release/main
結果
AC  
実行時間 0 ms / 2,000 ms
+ 760µs
コード長 427 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 383 ms
コンパイル使用メモリ 182,492 KB
実行使用メモリ 6,528 KB
最終ジャッジ日時 2026-09-14 20:01:47
合計ジャッジ時間 1,970 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 15
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

use std::io::{ self, prelude::* };

fn main() {
    let mut s = String::new();
    io::stdin().read_to_string(&mut s).unwrap();
    let mut tokens = s.split_whitespace();

    let mut n: u64 = tokens.next().unwrap().parse().unwrap();

    let mut ans = 0;
    while n != 1 {
        if n & 1 == 1 {
            n += 1;
        }
        else {
            n >>= 1;
        }
        ans += 1;
    }

    println!("{}", ans);
}
0