結果

問題 No.598 オーバーフローファンタジー
ユーザー phspls
提出日時 2020-05-07 22:20:41
言語 Rust
(1.83.0 + proconio)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 736 bytes
コンパイル時間 11,512 ms
コンパイル使用メモリ 402,052 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-07-03 09:36:19
合計ジャッジ時間 12,755 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #

use std::cmp::min;

fn main() {
    let mut n = String::new();
    std::io::stdin().read_line(&mut n).ok();
    let n: usize = n.trim().parse().unwrap();
    let mut x = String::new();
    std::io::stdin().read_line(&mut x).ok();
    let x: usize = x.trim().parse().unwrap();
    let mut a = String::new();
    std::io::stdin().read_line(&mut a).ok();
    let a: usize = a.trim().parse().unwrap();
    let mut b = String::new();
    std::io::stdin().read_line(&mut b).ok();
    let b: usize = b.trim().parse().unwrap();

    let rest = (1 << ((n-1) as usize)) - x;
    let result = rest / b + if rest % b == 0 { 0 } else { 1 };
    let result = min(result as usize, x / a + if x % a == 0 { 0 } else { 1 });
    println!("{}", result);
}
0