记录编号 79440 评测结果 AWWWW
题目名称 [NOI 1998]个人所得税 最终得分 20
用户昵称 GravatarAlan 是否通过 未通过
代码语言 Pascal 运行时间 0.012 s
提交时间 2013-11-05 18:30:47 内存使用 2.45 MiB
显示代码纯文本
var
  a:array[1..50000,1..12]of longint;
  ans:real;
  n,i,j,k:longint;
  ch:char;

        procedure rq(var j:longint);
        var
          c:char;
        begin
          repeat read(ch) until ch<>' ';
          if ch='1' then
            begin
              read(ch);
              if ch='/' then
                j:=1
              else
                j:=ord(ch)-38;
            end
          else j:=ord(ch)-48;
        end;

        function income(k:longint):real;
        var
          x:real;
        begin
          if k<=4000 then
            x:=k-800
          else x:=k*0.8;
          if x<0.000001 then begin income:=0;exit;end;
          if x<=20000 then
            income:=x*0.2
          else if x<=50000 then
            income:=4000+(x-20000)*0.3
          else
            income:=13000+(x-50000)*0.4;
        end;

        function pay(k:longint):real;
        begin
          k:=k-800;
          if k<=0 then exit;
          if k<500 then
            pay:=k*0.05
          else if k<2000 then
            pay:=25+(k-500)*0.1
          else if k<5000 then
            pay:=175+(k-2000)*0.15
          else if k<20000 then
            pay:=625+(k-5000)*0.2
          else if k<40000 then
            pay:=3625+(k-20000)*0.25
          else if k<60000 then
            pay:=8625+(k-40000)*0.3
          else if k<80000 then
            pay:=14625+(k-60000)*0.35
          else if k<100000 then
            pay:=21625+(k-80000)*0.4
          else
            pay:=29625+(k-100000)*0.45;
        end;

begin
  assign(input,'personaltax.in');
  assign(output,'personaltax.out');
  reset(input);
  rewrite(output);

  fillchar(a,sizeof(a),0);
  ans:=0;
  readln(n);
  read(ch);
  repeat
    if ch='P' then
      begin
        repeat read(ch) until ch=' ';
        read(i);
        rq(j);
        repeat read(ch) until ch=' ';
        readln(k);
        a[i,j]:=a[i,j]+k;
      end
    else
      begin
        repeat read(ch) until ch=' ';
        repeat read(ch) until ch<>' ';
        repeat read(ch) until ch=' ';
        repeat read(ch) until ch<>' ';
        repeat read(ch) until ch=' ';
        readln(k);
        ans:=ans+income(k);
      end;
    read(ch);
  until ch='#';

  for i:=1 to n do
    for j:=1 to 12 do
      if a[i,j]>0 then
        ans:=ans+pay(a[i,j]);

  writeln(ans:0:2);

  close(input);
  close(output);
end.