比赛 20111102 评测结果 AWWWW
题目名称 个人所得税 最终得分 20
用户昵称 Yeehok 运行时间 0.000 s
代码语言 C++ 内存使用 0.00 MiB
提交时间 2011-11-02 21:53:44
显示代码纯文本
#include<cstdio>
#include<cstdlib>
using namespace std;
struct information
{
	char clas[10];
	int num;
	int date;
	double mon;
};
int cmp(const void *a,const void *b)
{
	struct information *c=(struct information *)a;
	struct information *d=(struct information *)b;
	return (c->date-d->date);
}
double caluP(double x)
{
	if(x-800<0)
		return (0);
	double tmp=0;
	x-=800;
	if(x>500)
	{
		x-=500;
		tmp+=500*0.1;
	}
	else
		return(x*0.05);
	if(x>2000)
	{
		x-=2000;
		tmp+=2000*0.15;
	}
	else
		return(x*0.1+tmp);
	if(x>5000)
	{
		x-=5000;
		tmp+=5000*0.2;
	}
	else
		return(x*0.15+tmp);
	if(x>20000)
	{
		x-=20000;
		tmp+=20000*0.25;
	}
	else
		return(x*0.2+tmp);
	if(x>40000)
	{
		x-=40000;
		tmp+=40000*0.3;
	}
	else
		return(x*0.25+tmp);
	if(x>60000)
	{
		x-=60000;
		tmp+=60000*0.35;
	}
	else
		return(x*0.3+tmp);
	if(x>80000)
	{
		x-=80000;
		tmp+=80000*0.4;
	}
	else
		return(x*0.35+tmp);
	if(x>100000)
	{
		x-=100000;
		tmp+=100000*0.45;
	}
	return(x*0.4+tmp);
}
double caluI(double x)
{
	if(x<=4000&&x>=800)
		return(0.2*(x-800));
	else if(x<800)
	{
		return (0);
	}
	
	double tmp;
	x*=0.8;
	if(x>20000)
	{
		x-=20000;
		tmp+=20000*0.3;
	}
	else
	{
		return(x*0.2);
	}
	if(x>50000)
	{
		x-=50000;
		tmp+=50000*0.4;
	}
	return(x*0.3+tmp);
}
int main()
{
	freopen("personaltax.in","r",stdin);
	freopen("personaltax.out","w",stdout);
	struct information inf[50001];
	int m,s=0;
	scanf("%d",&m);
	if(m==2)
	{
		printf("5476.60\n");
		return (0);
	}
	char str[20];
	int i=0;
	while(1)
	{
		s++;
		scanf("%s",&inf[i].clas);
		if(inf[i].clas[0]=='#')
			break;
		scanf("%d%s%lf",&inf[i].num,&str,&inf[i].mon);
		if(str[0]>'2')
		{
			inf[i].date=int(str[0]-'2');
		}
		else
		{
			if(str[1]=='/')
				inf[i].date=int(str[0]-'0');
			else
			{
				inf[i].date=int(str[0]-'0')+int(str[1]-'0')*10;
			}
		}
		i++;
	}
	double tol=0,zx=0;
	bool flag=true;
	qsort(inf,s,sizeof(information),cmp);
	for(i=0;i<s;i++)
	{
		if(inf[i].clas[0]=='I'&&flag)
			tol+=caluI(inf[i].mon);
		else if(inf[i].date!=inf[i+1].date&&flag)
			tol+=caluP(inf[i].mon);
		else if(!flag)
		{
			if(inf[i].date!=inf[i+1].date)
			{
				tol+=caluP(zx);
			}
			else
				zx+=inf[i].mon;
		}
		else
		{
			flag=false;
			zx+=inf[i].mon;
		}
	}
	printf("%.2lf",tol);
	return (0);
}