比赛 20111102 评测结果 AWWWE
题目名称 个人所得税 最终得分 20
用户昵称 lizhe 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2011-11-02 21:54:52
显示代码纯文本
program personaltax;
var
  i,j,m,t,mon,num,ney:longint;
  s,p:string;
  money:real;
  month:array[1..50000,1..12]of real;
  k:integer;
  sum:real;
procedure init;
begin
  assign(input,'personaltax.in');
  reset(input);
  assign(output,'personaltax.out');
  rewrite(output);
  readln(m)
end;

procedure block;
begin
  while s[1]=' ' do
    delete(s,1,1)
end;

procedure pay;
begin
  delete(s,1,3);
  block;
  t:=pos(' ',s);
  p:=copy(s,1,t-1);
  delete(s,1,t);
  block;
  val(p,num,k);
  t:=pos('/',s);
  p:=copy(s,1,t-1);
  val(p,mon,k);
  t:=pos(' ',s);
  delete(s,1,t);
  val(s,ney,k);
  money:=ney;
  month[num,mon]:=month[num,mon]+money
end;

procedure income;
begin
  delete(s,1,6);
  block;
  t:=pos(' ',s);
  repeat
    delete(s,1,t);
    t:=pos(' ',s)
  until t=0;
  val(s,ney,k);
  money:=ney;
  if (money>800) and (money<=4000) then sum:=sum+(money-800)*0.2;
  if money>4000 then
  begin
    sum:=sum+640;
    money:=(money-4000)*0.8;
	  if money<=20000 then sum:=sum+money*0.2;
    if (money>20000) and (money<=50000) then sum:=sum+4000+(sum-20000)*0.3;
    if money>50000 then sum:=sum+13000+(sum-50000)*0.4
  end
end;

procedure main;
begin
  readln(s);
  repeat
    block;
    while s[length(s)]=' ' do delete(s,length(s),1);
    if s[1]='P' then pay;
    if s[1]='I' then income;
    readln(s)
  until s='#';
  for i:=1 to m do
    for j:=1 to 12 do
    begin
      money:=month[i,j];
	    if money>800 then
      begin
        money:=money-800;
        if money<=500 then sum:=sum+money*0.05;
        if (money>500) and (money<=2000) then sum:=sum+25+(money-500)*0.1;
        if (money>2000) and (money<=5000) then sum:=sum+175+(money-2000)*0.15;
        if (money>5000) and (money<=20000) then sum:=sum+625+(money-5000)*0.2;
        if (money>20000) and (money<=40000) then sum:=sum+3625+(money-20000)*0.25;
        if (money>40000) and (money<=60000) then sum:=sum+8625+(money-40000)*0.3;
        if (money>60000) and (money<=80000) then sum:=sum+14625+(money-60000)*0.35;
        if (money>80000) and (money<=100000) then sum:=sum+21625+(money-80000)*0.4;
        if money>100000 then sum:=sum+29625+(money-100000)*0.45
      end
    end
end;

procedure print;
begin
  writeln(sum:0:2);
  close(input);
  close(output)
end;

begin
  init;
  main;
  print
end.