結果
問題 | No.642 Two Operations No.1 |
ユーザー |
|
提出日時 | 2018-02-02 23:17:31 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 1 ms / 2,000 ms |
コード長 | 1,624 bytes |
コンパイル時間 | 13,487 ms |
コンパイル使用メモリ | 398,608 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-12-31 08:11:58 |
合計ジャッジ時間 | 14,701 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 15 |
コンパイルメッセージ
warning: constant `M` is never used --> src/main.rs:26:7 | 26 | const M: usize = 1_000_007; | ^ | = note: `#[warn(dead_code)]` on by default
ソースコード
#![allow(unused_imports)]use std::io::{ self, Write };use std::str::FromStr;use std::cmp::{ min, max };use std::collections::{ BinaryHeap, VecDeque };#[allow(unused_macros)]macro_rules! trace {($var:expr) => {let _ = writeln!(&mut std::io::stderr(), ">>> {} = {:?}", stringify!($var), $var);};($($args:expr),*) => { trace!(($($args),*)) }}#[allow(unused_macros)]macro_rules! put {($var:expr) => {let _ = writeln!(&mut std::io::stdout(), "{}", $var);};($var:expr, $($args:expr),*) => {let _ = write!(&mut std::io::stdout(), "{} ", $var);put!($($args),*);};}const M: usize = 1_000_007;fn main() {let mut sc = Scanner::new();let mut x: usize = sc.cin();let mut a = 0;while x > 1 {if x % 2 == 0 {x /= 2;} else {x += 1;}a += 1;}put!(a);}#[allow(dead_code)]struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }#[allow(dead_code)]impl Scanner {fn new() -> Scanner { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }fn reserve(&mut self) {while self.buffer.len() == 0 {let mut line = String::new();let _ = self.stdin.read_line(&mut line);for w in line.split_whitespace() {self.buffer.push_back(String::from(w));}}}fn cin<T: FromStr>(&mut self) -> T {self.reserve();match self.buffer.pop_front().unwrap().parse::<T>() {Ok(a) => a,Err(_) => panic!("parse err")}}}