結果

問題 No.47 ポケットを叩くとビスケットが2倍
ユーザー _yoshih_
提出日時 2018-09-29 23:48:01
言語 Rust
(1.83.0 + proconio)
結果
AC  
実行時間 1 ms / 5,000 ms
コード長 538 bytes
コンパイル時間 14,374 ms
コンパイル使用メモリ 393,020 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-10-12 08:54:54
合計ジャッジ時間 13,295 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

use std::io::*;
use std::str::*;

fn read<T: FromStr>(sl: &mut StdinLock) -> Option<T> {
    let s = sl.by_ref().bytes().map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();

    s.parse::<T>().ok()
}

fn run(sl: &mut StdinLock) {
    let n = read::<u32>(sl).unwrap();
    let r = (0..).map(|i| 2u32.pow(i)).take_while(|&k| k < n).count();
    println!("{}", r);
}

fn main() {
    let s = stdin();
    let mut sl = s.lock();
    run(&mut sl);
}
0