记录编号 79060 评测结果 AAAAA
题目名称 [NOI 1998]个人所得税 最终得分 100
用户昵称 Gravatarraywzy 是否通过 通过
代码语言 C++ 运行时间 0.005 s
提交时间 2013-11-04 23:38:03 内存使用 5.27 MiB
显示代码纯文本
#include<fstream>
#include<string>
#include<iomanip>
#include<cmath>
using namespace std;
ifstream fin("personaltax.in");
ofstream fout("personaltax.out");
double f[50001][13];//某个人在某个月的工资薪金
int n;
double ANS=0;
double jisuan1(double a)//月计算
{
	if(a<=0) return 0;
	double counter=0;
	double temp=a;
	if(a<=500)
		return a*0.05;
	else
		counter+=500*0.05;
	if(a<=2000)
		return counter+(a-500)*0.1;
	else
		counter+=1500*0.1;
	if(a<=5000)
		return counter+=(a-2000)*0.15;
	else
		counter+=3000*0.15;
	if(a<=20000)
		return counter+=(a-5000)*0.2;
	else
		counter+=15000*0.2;
	if(a<=40000)
		return counter+=(a-20000)*0.25;
	else
		counter+=20000*0.25;
	if(a<=60000)
		return counter+=(a-40000)*0.3;
	else
		counter+=20000*0.3;
	if(a<=80000)
		return counter+=(a-60000)*0.35;
	else
		counter+=20000*0.35;
	if(a<=100000)
		return counter+=(a-80000)*0.4;
	else
		counter+=20000*0.4;
	if(a>100000)
		return counter+=(a-100000)*0.45;
}
double jisuan2(double a)
{
	if(a<=0) return 0;
	double counter=0;
	if(a<=20000)
		return a*0.2;
	else
		counter+=20000*0.2;
	if(a<=50000)
		return counter+=(a-20000)*0.3;
	else
		counter+=30000*0.3;
	if(a>50000)
		return counter+=(a-50000)*0.4;
}
int pow(int x,int y)
{
	int temp=1;
	int i;
	for(i=1;i<=y;i++)
		temp=temp*x;
	return temp;
}
int ZH(string A)
{
	int LA=A.length();
	int i;
	int K;
	int temp=0;
	for(i=LA-1;i>=0;i--)
	{
		K=pow(10,LA-i-1);
		temp+=(int(A[i])-48)*K;
	}
	return temp;
}
int main()
{
	fin>>n;
	int temp;
	int mouth;
	string New="";
	double tot;
	string A,B,C,D;
	int i,j;
	while(!fin.eof())
	{
		fin>>A>>B>>C>>D;
		if(A[0]=='#')
			break;
		if(A[0]=='P')
		{
			temp=ZH(B);//某个职员
			New+=C[0];
			if(C[1]!='/')
				New+=C[1];
			mouth=ZH(New);
			New="";
			tot=ZH(D);
			f[temp][mouth]+=tot;
		}
		else
		{
			tot=ZH(D);
			if(tot<=4000)
			tot=jisuan2(tot-800);
			else
				tot=jisuan2(tot*0.8);
			ANS+=tot;
		}
	}
	for(i=1;i<=n;i++)
		for(j=1;j<=12;j++)
		{
			ANS+=jisuan1(f[i][j]-800);
		}
	fout<<setiosflags(ios::fixed)<<setprecision(2)<<ANS<<endl;
	return 0;
}