记录编号 58739 评测结果 AAAAA
题目名称 [NOI 1998]个人所得税 最终得分 100
用户昵称 Gravatarcstdio 是否通过 通过
代码语言 C++ 运行时间 0.000 s
提交时间 2013-04-25 20:55:06 内存使用 0.00 MiB
显示代码纯文本
  1. #include<iostream>
  2. #include<cstdio>
  3. #include<iomanip>
  4. #include<map>
  5. #include<set>
  6. #include<deque>
  7. #include<cstring>
  8. #include<cmath>
  9. #include<algorithm>
  10. #include<cstdlib>
  11. using namespace std;
  12. double msal(double s){//月薪
  13. s-=800;
  14. double ans=0;
  15. if(s<=0) return 0;
  16. if(s<=500){
  17. ans+=s*5/100;
  18. return ans;
  19. }
  20. ans+=500*5/100;
  21. s-=500;
  22. if(s<=1500){//~2000
  23. ans+=s*10/100;
  24. return ans;
  25. }
  26. ans+=1500*10/100;
  27. s-=1500;
  28. if(s<=3000){//~5000
  29. ans+=s*15/100;
  30. return ans;
  31. }
  32. ans+=3000*15/100;
  33. s-=3000;
  34. if(s<=15000){//~20000
  35. ans+=s*20/100;
  36. return ans;
  37. }
  38. ans+=15000*20/100;
  39. s-=15000;
  40. if(s<=20000){//~40000
  41. ans+=s*25/100;
  42. return ans;
  43. }
  44. ans+=20000*25/100;
  45. s-=20000;
  46. if(s<=20000){//~60000
  47. ans+=s*30/100;
  48. return ans;
  49. }
  50. ans+=20000*30/100;
  51. s-=20000;
  52. if(s<=20000){//~80000
  53. ans+=s*35/100;
  54. return ans;
  55. }
  56. ans+=20000*35/100;
  57. s-=20000;
  58. if(s<=20000){//~100000
  59. ans+=s*40/100;
  60. return ans;
  61. }
  62. ans+=20000*40/100;
  63. s-=20000;
  64. ans+=s*45/100;
  65. return ans;
  66. }
  67. double tsal(double s){//单次
  68. if(s<=4000) s-=800;
  69. else s*=0.8;
  70. double ans=0;
  71. if(s<=0) return 0;
  72. if(s<=20000){//~20000
  73. ans+=s*20/100;
  74. return ans;
  75. }
  76. ans+=20000*20/100;
  77. s-=20000;
  78. if(s<=30000){
  79. ans+=s*30/100;
  80. return ans;
  81. }
  82. ans+=30000*30/100;
  83. s-=30000;
  84. ans+=s*40/100;
  85. return ans;
  86. }
  87. string str;
  88. const int SIZEN=50001;//职员人数
  89. int n;
  90. double mp[SIZEN][15]={0};//每人月薪
  91. double ans[SIZEN]={0};//每人税额
  92. void work(void){
  93. scanf("%d",&n);
  94. int pos,mon,day;
  95. double sal;
  96. do{
  97. cin>>str;
  98. if(str=="#") break;
  99. if(str=="PAY"){//月薪
  100. scanf("%d%d",&pos,&mon);
  101. getchar();
  102. scanf("%d%lf",&day,&sal);
  103. mp[pos][mon]+=sal;
  104. }
  105. else{//单次
  106. scanf("%d%d",&pos,&mon);
  107. getchar();
  108. scanf("%d%lf",&day,&sal);
  109. ans[pos]+=tsal(sal);
  110. }
  111. }while(str!="#");
  112. cout<<setiosflags(ios::fixed)<<setprecision(2);
  113. double sum=0;
  114. int i,j;
  115. for(i=1;i<=n;i++){
  116. for(j=1;j<=12;j++){
  117. ans[i]+=msal(mp[i][j]);
  118. }
  119. sum+=ans[i];
  120. }
  121. cout<<sum<<endl;
  122. }
  123. int main(){
  124. freopen("personaltax.in","r",stdin);
  125. freopen("personaltax.out","w",stdout);
  126. work();
  127. return 0;
  128. }