记录编号 79082 评测结果 AAAAA
题目名称 [NOI 1998]个人所得税 最终得分 100
用户昵称 Gravatardigital-T 是否通过 通过
代码语言 C++ 运行时间 0.016 s
提交时间 2013-11-05 06:55:39 内存使用 2.77 MiB
显示代码纯文本
#include<cstdio>
#include<iomanip>
#include<cstring>
#include<string>
#include<cstdlib>
#include<cmath>
#include<algorithm>
using namespace std;
int M,person[50001][13];
double Ans=0.0;
void ONCE_INCOME(int cash)
{
	if(cash<=800)return;
	double left;
	if(cash<=4000)left=(double)(cash-800);
	else left=(double)cash,left*=0.8;
	if(left<=20000.0){Ans+=(left*0.2);return;}
	Ans+=20000.0*0.2;left-=20000.0;
	if(left<=30000.0){Ans+=(left*0.3);return;}
	Ans+=30000.0*0.3;left-=30000.0;
	if(left>0.0){Ans+=(left*0.4);return;}
}
void MONTH_PAYOFF(int cash)
{
	if(cash<=800)return;
	double left=(double)(cash-800);
	if(left<=500.0){Ans+=left*0.05;return;}
	Ans+=500.0*0.05;left-=500.0;
	if(left<=1500.0){Ans+=left*0.1;return;}
	Ans+=1500.0*0.1;left-=1500.0;
	if(left<=3000.0){Ans+=left*0.15;return;}
	Ans+=3000.0*0.15;left-=3000.0;
	if(left<=15000.0){Ans+=left*0.2;return;}
	Ans+=15000.0*0.2;left-=15000.0;
	if(left<=20000.0){Ans+=left*0.25;return;}
	Ans+=20000.0*0.25;left-=20000.0;
	if(left<=20000.0){Ans+=left*0.3;return;}
	Ans+=20000.0*0.3;left-=20000.0;
	if(left<=20000.0){Ans+=left*0.35;return;}
	Ans+=20000.0*0.35;left-=20000.0;
	if(left<=20000.0){Ans+=left*0.4;return;}
	Ans+=20000.0*0.4;left-=20000.0;
	if(left>0.0){Ans+=left*0.45;return;}
}
int main()
{
	freopen("personaltax.in","r",stdin);
	freopen("personaltax.out","w",stdout);
	memset(person,0,sizeof(person));
	scanf("%d",&M);
	char task[7]={' '},tmp;int number,month,day,cash;
	for(;task[0]!='#';)
	{
		scanf("%s",&task);
		if(task[0]=='#')continue;
		scanf("%d",&number);
		scanf("%d%c%d",&month,&tmp,&day);
		scanf("%d",&cash);
		if(task[0]=='P')person[number][month]+=cash;
		else ONCE_INCOME(cash);
	}
	for(int i=1;i<=M;i++)
		for(int j=1;j<=12;j++)
			MONTH_PAYOFF(person[i][j]);
	printf("%.2lf\n",Ans);
	return 0;
}