比赛 20111102 评测结果 AAAAA
题目名称 个人所得税 最终得分 100
用户昵称 kaaala 运行时间 0.000 s
代码语言 C++ 内存使用 0.00 MiB
提交时间 2011-11-02 19:18:44
显示代码纯文本
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>

using namespace std;

const int sd[10]={0,500,2000,5000,20000,40000,60000,80000,100000,1000000000},sl[]={0,5,10,15,20,25,30,35,40,45};

int m;
double ans,z[50001][13];

double INCOME(double x)
{
	if(x<=4000)
		x-=800;
	else
		x*=0.8;
	if(x<0)
		return 0;
	if(x<=20000)
		return x*0.2;
	if(x<=50000)
		return (x-20000)*0.3+4000;
	return (x-50000)*0.4+13000;
}

double PAY(int x)
{
	x-=800;
	if(x<=0)
		return 0;
	double re=0;
	for(int i=1;i<=9;++i)
	{
		if(x<=sd[i])
			return (re+(x-sd[i-1])*sl[i])/100;
		re+=sl[i]*(sd[i]-sd[i-1]);
	}
}

int main()
{
	freopen("personaltax.in","r",stdin);
	freopen("personaltax.out","w",stdout);
	scanf("%d",&m);
	for(;;)
	{
		char s[10];
		scanf("%s",s);
		if(s[0]=='#')
			break;
		int a,b,d,e;
		char c;
		scanf("%d%d%c%d%d",&a,&b,&c,&d,&e);
		if(s[0]=='I')
			z[a][0]+=INCOME(e);
		else
			z[a][b]+=e;
	}
	for(int i=1;i<=m;++i)
	{
		ans+=z[i][0];
		for(int j=1;j<=12;++j)
			ans+=PAY(z[i][j]);
	}
	printf("%.2lf\n",ans);
	return 0;
}