結果

問題 No.928 軽減税率?
ユーザー fukafukatani
提出日時 2019-11-22 22:22:25
言語 Rust
(1.37.0)
結果
WA   .
実行時間 -
コード長 1,552 Byte
コンパイル時間 1,096 ms
使用メモリ 964 KB
最終ジャッジ日時 2019-11-22 22:22:36

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
A_sample_0.txt AC 218 ms
960 KB
A_sample_1.txt AC 217 ms
964 KB
B_random_2.txt WA -
B_random_3.txt WA -
B_random_4.txt AC 216 ms
960 KB
B_random_5.txt AC 217 ms
956 KB
B_random_6.txt AC 219 ms
956 KB
B_random_7.txt AC 217 ms
960 KB
B_random_8.txt AC 217 ms
960 KB
B_random_9.txt AC 218 ms
960 KB
B_random_10.txt AC 217 ms
960 KB
B_random_11.txt AC 216 ms
956 KB
B_random_12.txt AC 218 ms
964 KB
B_random_13.txt AC 217 ms
956 KB
B_random_14.txt AC 219 ms
960 KB
B_random_15.txt AC 217 ms
960 KB
B_random_16.txt AC 217 ms
964 KB
C_hand_17.txt AC 217 ms
956 KB
C_hand_18.txt AC 219 ms
960 KB
C_hand_19.txt AC 218 ms
960 KB
C_hand_20.txt AC 217 ms
956 KB
C_hand_21.txt AC 217 ms
960 KB
C_hand_22.txt WA -
C_hand_23.txt WA -
C_hand_24.txt WA -
D_tester_25.txt WA -
D_tester_26.txt WA -
D_tester_27.txt WA -
D_tester_28.txt WA -
D_tester_29.txt WA -
D_tester_30.txt WA -
D_tester_31.txt WA -
D_tester_32.txt WA -
D_tester_33.txt WA -
D_tester_34.txt WA -
D_tester_35.txt WA -
テストケース一括ダウンロード
コンパイルメッセージ
warning: function is never used: `binary_search`
  --> Main.rs:57:1
   |
57 | / fn binary_search<F>(lb: i64, ub: i64, criterion: F) -> (i64, i64)
58 | | where
59 | |     F: Fn(i64) -> bool,
60 | | {
...  |
71 | |     (ok, ng)
72 | | }
   | |_^
   |
   = note: #[warn(dead_code)] on by default

ソースコード

diff #
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<i64>();
    let (p, q, a) = (v[0], v[1], v[2]);
    if p == q {
        if a == 0 {
            println!("{}", 0);
        } else {
            println!("{}", 1000000000);
        }
    }

    let criterion = |x| x * p / 100 < x * q / 100 + a;
    let mut ans = 0;
    for i in 1..100000000 {
        if criterion(i) {
            ans += 1;
        }
    }

    /*
    let criterion = |x| x * p / 100 < x * q / 100 + a;
    let ans = binary_search(0, 1000000001, criterion).0;
    */
    println!("{}", ans);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn binary_search<F>(lb: i64, ub: i64, criterion: F) -> (i64, i64)
where
    F: Fn(i64) -> bool,
{
    let mut ok = lb;
    let mut ng = ub;
    while ng - ok > 1 {
        let mid = (ng + ok) / 2;
        if criterion(mid) {
            ok = mid;
        } else {
            ng = mid;
        }
    }
    (ok, ng)
}
0