結果

問題 No.928 軽減税率?
ユーザー phsplsphspls
提出日時 2020-02-01 00:44:28
言語 Rust
(1.77.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 1,474 bytes
コンパイル時間 7,228 ms
コンパイル使用メモリ 164,364 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-17 15:16:03
合計ジャッジ時間 2,458 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 1 ms
4,348 KB
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 AC 1 ms
4,348 KB
testcase_23 AC 1 ms
4,348 KB
testcase_24 AC 1 ms
4,348 KB
testcase_25 AC 1 ms
4,348 KB
testcase_26 AC 1 ms
4,348 KB
testcase_27 AC 1 ms
4,348 KB
testcase_28 AC 1 ms
4,348 KB
testcase_29 AC 1 ms
4,348 KB
testcase_30 AC 1 ms
4,348 KB
testcase_31 AC 1 ms
4,348 KB
testcase_32 AC 1 ms
4,348 KB
testcase_33 AC 1 ms
4,348 KB
testcase_34 AC 1 ms
4,348 KB
testcase_35 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

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 { 0 } else { 10i32.pow(9) });
    } else if q > p && a > 0 {
        println!("{}", 10i32.pow(9));
    } 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+2) * 10_000 + (10i32.pow(9) as isize));
        }
    }
}
0