记录编号 58739 评测结果 AAAAA
题目名称 [NOI 1998]个人所得税 最终得分 100
用户昵称 Gravatarcstdio 是否通过 通过
代码语言 C++ 运行时间 0.000 s
提交时间 2013-04-25 20:55:06 内存使用 0.00 MiB
显示代码纯文本
#include<iostream>
#include<cstdio>
#include<iomanip>
#include<map>
#include<set>
#include<deque>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdlib>
using namespace std;
double msal(double s){//月薪
	s-=800;
	double ans=0;
	if(s<=0) return 0;
	if(s<=500){
		ans+=s*5/100;
		return ans;
	}
	ans+=500*5/100;
	s-=500;
	if(s<=1500){//~2000
		ans+=s*10/100;
		return ans;
	}
	ans+=1500*10/100;
	s-=1500;
	if(s<=3000){//~5000
		ans+=s*15/100;
		return ans;
	}
	ans+=3000*15/100;
	s-=3000;
	if(s<=15000){//~20000
		ans+=s*20/100;
		return ans;
	}
	ans+=15000*20/100;
	s-=15000;
	if(s<=20000){//~40000
		ans+=s*25/100;
		return ans;
	}
	ans+=20000*25/100;
	s-=20000;
	if(s<=20000){//~60000
		ans+=s*30/100;
		return ans;
	}
	ans+=20000*30/100;
	s-=20000;
	if(s<=20000){//~80000
		ans+=s*35/100;
		return ans;
	}
	ans+=20000*35/100;
	s-=20000;
	if(s<=20000){//~100000
		ans+=s*40/100;
		return ans;
	}
	ans+=20000*40/100;
	s-=20000;
	ans+=s*45/100;
	return ans;
}
double tsal(double s){//单次
	if(s<=4000) s-=800;
	else s*=0.8;
	double ans=0;
	if(s<=0) return 0;
	if(s<=20000){//~20000
		ans+=s*20/100;
		return ans;
	}
	ans+=20000*20/100;
	s-=20000;
	if(s<=30000){
		ans+=s*30/100;
		return ans;
	}
	ans+=30000*30/100;
	s-=30000;
	ans+=s*40/100;
	return ans;
}
string str;
const int SIZEN=50001;//职员人数
int n;
double mp[SIZEN][15]={0};//每人月薪
double ans[SIZEN]={0};//每人税额
void work(void){
	scanf("%d",&n);
	int pos,mon,day;
	double sal;
	do{
		cin>>str;
		if(str=="#") break;
		if(str=="PAY"){//月薪
			scanf("%d%d",&pos,&mon);
			getchar();
			scanf("%d%lf",&day,&sal);
			mp[pos][mon]+=sal;
		}
		else{//单次
			scanf("%d%d",&pos,&mon);
			getchar();
			scanf("%d%lf",&day,&sal);
			ans[pos]+=tsal(sal);
		}
	}while(str!="#");
	cout<<setiosflags(ios::fixed)<<setprecision(2);
	double sum=0;
	int i,j;
	for(i=1;i<=n;i++){
		for(j=1;j<=12;j++){
			ans[i]+=msal(mp[i][j]);
		}
		sum+=ans[i];
	}
	cout<<sum<<endl;
}
int main(){
	freopen("personaltax.in","r",stdin);
	freopen("personaltax.out","w",stdout);
	work();
	return 0;
}