結果

問題 No.928 軽減税率?
ユーザー iicafiaxusiicafiaxus
提出日時 2019-11-22 23:08:00
言語 D
(dmd 2.107.1)
結果
AC  
実行時間 6 ms / 1,000 ms
コード長 2,150 bytes
コンパイル時間 837 ms
コンパイル使用メモリ 124,968 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-04 03:24:27
合計ジャッジ時間 2,072 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); }
void log()(){ writeln(""); } void log(T, A ...)(T t, lazy A a){ if(DEBUG) write(t, " "), log(a); } bool DEBUG = 0; 
string rstring(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T rtype(T)(){ return rstring.to!T; } alias rint = rtype!int, rlong = rtype!long, rreal = rtype!real;
T[] rtypes(T)(int n){ return n.iota.map!(i => rtype!T()).array; } alias rint = rtypes!int, rlong = rtypes!long, rreal = rtypes!real;
T[][] rtypess(T)(int n, int m){ return n.iota.map!(i => rtypes!T(m)).array; } alias rint = rtypess!int, rlong = rtypess!long, rreal = rtypess!real;

// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- //

void solve(){
	long p = rlong, q = rlong, a = rlong;
	
	long ans;
	if(p > q){
		foreach(x; 1 .. 1_000_000_001){
			if(x * (p - q) >= 100 * a) break;
			if((100 + p) * x / 100 < ((100 + q) * x + 100 * a) / 100) ans += 1;
		}
	}
	else if(p == q){
		if(a > 0) ans = 1_000_000_000;
		else ans = 0;
	}
	else{
		ans = 1_000_000_000;
		foreach(x; 1 .. 1_000_000_001){
			if(x * (q - p) >= 100 - 100 * a) break;
			if((100 + p) * x / 100 >= ((100 + q) * x + 100 * a) / 100) ans -= 1;
		}
	}
	ans.writeln;
}

/*
floor((1 + p / 100) x) < floor((1 + q / 100) x + a)
をみたす x を求める。

p > q の場合:
必要条件として
(1 + p / 100) x < (1 + q / 100) x + a
(100 + p) x < (100 + q) x + 100 a
(p - q) x < 100 a
x < 100 a / (p - q)
この範囲を全検査すればよい

p < q の場合:
みたさない x を求める。
floor((1 + p / 100) x) >= floor((1 + q / 100) x + a)
ただし、ここで (1 + p / 100) x < (1 + q / 100) x + a なので、
上記は floor((1 + p / 100) x) = floor((1 + q / 100) x + a)
必要条件として
(1 + q / 100) x + a < (1 + p / 100) x + 1
(100 + q) x < (100 + p) x  + 100 - 100 a
(q - p) x < 100 - 100 a
この範囲を全検査すれば良い

*/
0