結果

問題 No.598 オーバーフローファンタジー
コンテスト
ユーザー aimy
提出日時 2017-11-24 22:36:23
言語 Rust
(1.94.0 + proconio + num + itertools)
コンパイル:
/usr/bin/rustc_custom
実行:
./target/release/main
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 2,399 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 3,500 ms
コンパイル使用メモリ 193,884 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2026-05-31 19:28:59
合計ジャッジ時間 3,071 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 28
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: use of deprecated method `core::str::<impl str>::trim_right`: superseded by `trim_end`
  --> src/main.rs:21:9
   |
21 |     buf.trim_right().parse::<T>().ok().unwrap()
   |         ^^^^^^^^^^
   |
   = note: `#[warn(deprecated)]` on by default
help: replace the use of the deprecated method
   |
21 -     buf.trim_right().parse::<T>().ok().unwrap()
21 +     buf.trim_end().parse::<T>().ok().unwrap()
   |

warning: use of deprecated method `core::str::<impl str>::trim_right`: superseded by `trim_end`
  --> src/main.rs:36:22
   |
36 |     let mut it = buf.trim_right().split_whitespace();
   |                      ^^^^^^^^^^
   |
help: replace the use of the deprecated method
   |
36 -     let mut it = buf.trim_right().split_whitespace();
36 +     let mut it = buf.trim_end().split_whitespace();
   |

warning: use of deprecated method `core::str::<impl str>::trim_right`: superseded by `trim_end`
  --> src/main.rs:54:22
   |
54 |     let mut it = buf.trim_right().split_whitespace();
   |                      ^^^^^^^^^^
   |
help: replace the use of the deprecated method
   |
54 -     let mut it = buf.trim_right().split_whitespace();
54 +     let mut it = buf.trim_end().split_whitespace();
   |

warning: use of deprecated method `core::str::<impl str>::trim_right`: superseded by `trim_end`
  --> src/main.rs:73:9
   |
73 |     buf.trim_right().split_whitespace().map(|t| t.parse::<T>().ok().unwrap()).collect()
   |         ^^^^^^^^^^
   |
help: replace the use of the deprecated method
   |
73 -     buf.trim_right().split_whitespace().map(|t| t.parse::<T>().ok().unwrap()).collect()
73 +     buf.trim_end().split_whitespace().map(|t| t.parse::<T>().ok().unwrap()).collect()
   |

warning: use of deprecated method `core::str::<impl str>::trim_right`: superseded by `trim_end`
  --> src/main.rs:88:9
   |
88 |     buf.trim_right().chars().collect()
   |         ^^^^^^^^^^
   |
help: replace the use of the deprecated method
   |
88 -     buf.trim_right().chars().collect()
88 +

ソースコード

diff #
raw source code

fn main() {
  let n = get::val::<usize>();
  let x = get::val::<usize>();
  let a = get::val::<usize>();
  let b = get::val::<usize>();

  let attack = x / a + if x%a==0 {0} else {1};
  let heal = ((1 << (n-1))-x) / b + if ((1 << (n-1))-x) % b == 0 {0} else {1};
  println!("{}", std::cmp::min(attack, heal))
}

#[allow(dead_code)]
mod get {
  use std::io::*;
  use std::str::*;

  pub fn val<T: FromStr>() -> T {
    let mut buf = String::new();
    let s = stdin();
    s.lock().read_line(&mut buf).ok();
    buf.trim_right().parse::<T>().ok().unwrap()
  }

  pub fn vals<T: FromStr>(n: usize) -> Vec<T> {
    let mut vec: Vec<T> = vec![];
    for _ in 0 .. n {
      vec.push(val());
    }
    vec
  }

  pub fn tuple<T1: FromStr, T2: FromStr>() -> (T1, T2) {
    let mut buf = String::new();
    let s = stdin();
    s.lock().read_line(&mut buf).ok();
    let mut it = buf.trim_right().split_whitespace();
    let x = it.next().unwrap().parse::<T1>().ok().unwrap();
    let y = it.next().unwrap().parse::<T2>().ok().unwrap();
    (x, y)
  }

  pub fn tuples<T1: FromStr, T2: FromStr>(n: usize) -> Vec<(T1, T2)> {
    let mut vec: Vec<(T1, T2)> = vec![];
    for _ in 0 .. n {
      vec.push(tuple());
    }
    vec
  }

  pub fn tuple3<T1: FromStr, T2: FromStr, T3: FromStr>() -> (T1, T2, T3) {
    let mut buf = String::new();
    let s = stdin();
    s.lock().read_line(&mut buf).ok();
    let mut it = buf.trim_right().split_whitespace();
    let x = it.next().unwrap().parse::<T1>().ok().unwrap();
    let y = it.next().unwrap().parse::<T2>().ok().unwrap();
    let z = it.next().unwrap().parse::<T3>().ok().unwrap();
    (x, y, z)
  }

  pub fn tuple3s<T1: FromStr, T2: FromStr, T3: FromStr>(n: usize) -> Vec<(T1, T2, T3)> {
    let mut vec: Vec<(T1, T2, T3)> = vec![];
    for _ in 0 .. n {
      vec.push(tuple3());
    }
    vec
  }

  pub fn list<T: FromStr>() -> Vec<T> {
    let mut buf = String::new();
    let s = stdin();
    s.lock().read_line(&mut buf).ok();
    buf.trim_right().split_whitespace().map(|t| t.parse::<T>().ok().unwrap()).collect()
  }

  pub fn lists<T: FromStr>(h: usize) -> Vec<Vec<T>> {
    let mut mat: Vec<Vec<T>> = vec![];
    for _ in 0 .. h {
      mat.push(list());
    }
    mat
  }

  pub fn chars() -> Vec<char> {
    let mut buf = String::new();
    let s = stdin();
    s.lock().read_line(&mut buf).ok();
    buf.trim_right().chars().collect()
  }
}
0