记录编号 79046 评测结果 AAAAA
题目名称 [NOI 1998]个人所得税 最终得分 100
用户昵称 Gravatarzjmfrank2012 是否通过 通过
代码语言 C++ 运行时间 0.012 s
提交时间 2013-11-04 22:51:26 内存使用 2.79 MiB
显示代码纯文本
#include<fstream>
#include<iomanip>
using namespace std;
ifstream fi("personaltax.in");
ofstream fo("personaltax.out");
int n,t,t1,t2,i,j;
double ans=0;
string c;
int ma[13][50001]={0};
double pay(double x)
{
	if(x<=800)return 0;
	x=x-800;
	if(x<=500)return ((x+0.0)*0.05);
	if(x>500&&x<=2000)return ((x-500.0)*0.1+25.0);
	if(x>2000&&x<=5000)return ((x-2000.0)*0.15+175.0);
	if(x>5000&&x<=20000)return ((x-5000.0)*0.2+625.0);
	if(x>20000&&x<=40000)return ((x-20000.0)*0.25+3625.0);
	if(x>40000&&x<=60000)return ((x-40000.0)*0.3+8625.0);
	if(x>60000&&x<=80000)return ((x-60000.0)*0.35+14625.0);
	if(x>80000&&x<=100000)return ((x-80000.0)*0.4+21625.0);
	if(x>100000)return ((x-100000.0)*0.45+29625.0);
}
double income(double x)
{
	if(x<=800)return 0;
	if(x<=4000)x-=800;
	else x-=x*0.2;
	if(x<=20000)return ((x+0.0)*0.2);
	if(x>20000&&x<=50000)return ((x-20000.0)*0.3+4000.0);
	if(x>50000)return ((x-50000.0)*0.4+13000.0);
}
int main()
{
	fi>>n;
	while(1)
	{
		fi>>c;
		if(c=="#")break;
		if(c=="PAY")
		{
			fi>>t>>t1>>c>>t2;
			ma[t1][t]+=t2;
		}
		if(c=="INCOME")
		{
			fi>>t>>t1>>c>>t2;
			ans+=income(t2);
		}
	}
	for(i=1;i<=12;i++)
	{
		for(j=1;j<=n;j++)
		{
			ans+=pay(ma[i][j]);
		}
	}
	fo<<setiosflags(ios::fixed)<<setprecision(2)<<ans;
	return 0;
}