結果

問題 No.928 軽減税率?
ユーザー phsplsphspls
提出日時 2020-01-31 23:40:56
言語 Rust
(1.77.0)
結果
WA  
実行時間 -
コード長 1,429 bytes
コンパイル時間 883 ms
コンパイル使用メモリ 171,724 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-17 13:03:29
合計ジャッジ時間 3,479 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 1 ms
4,348 KB
testcase_05 AC 1 ms
4,348 KB
testcase_06 AC 1 ms
4,348 KB
testcase_07 AC 1 ms
4,348 KB
testcase_08 AC 1 ms
4,348 KB
testcase_09 AC 1 ms
4,348 KB
testcase_10 AC 1 ms
4,348 KB
testcase_11 AC 1 ms
4,348 KB
testcase_12 AC 1 ms
4,348 KB
testcase_13 AC 1 ms
4,348 KB
testcase_14 AC 1 ms
4,348 KB
testcase_15 AC 1 ms
4,348 KB
testcase_16 AC 1 ms
4,348 KB
testcase_17 AC 1 ms
4,348 KB
testcase_18 AC 1 ms
4,348 KB
testcase_19 AC 1 ms
4,348 KB
testcase_20 AC 1 ms
4,348 KB
testcase_21 AC 1 ms
4,348 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

use std::io::Read;
use std::cmp::{min, max};

fn eat(x: isize, p: isize) -> isize {
    (100+p) * x / 100
}

fn takeout(x: isize, q: isize, a: isize) -> isize {
    (100+q) * x / 100 + a
}

fn main() {
    let mut pqa = String::new();
    std::io::stdin().read_to_string(&mut pqa).ok();
    let pqa: Vec<isize> = pqa.trim().split('\n').next().unwrap().trim().split_whitespace().map(|i| i.parse::<isize>().unwrap()).collect();
    let p = pqa[0];
    let q = pqa[1];
    let a = pqa[2];
    if p == q {
        println!("{}", if a == 0 { 10i32.pow(9) } else { 0 });
    } else if q >= p {
        println!("{}", 0);
    } else {
        let mut switched_idx: isize = 0;
        for i in 0..100_000 {
            let start: isize = i * 10_000 + 1;
            let end: isize = (i+1) * 10_000;
            if (eat(start, p) - takeout(start, q, a)) * (eat(end, p) - takeout(end, q, a)) <= 0 {
                switched_idx = i;
                break;
            }
        }
        let mut result = 0;
        for i in max(0, switched_idx-1)..=min(100_000-1, switched_idx+1) {
            for j in 0..10_000 {
                result += if eat(i*10_000+j+1, p) < takeout(i*10_000+j+1, q, a) { 1 } else { 0 };
            }
        }
        if p > q {
            println!("{}", result + max(0, switched_idx-1) * 10_000);
        } else {
            println!("{}", result + min(100_000-1, switched_idx+1) * 10_000);
        }
    }
}
0