记录编号 79025 评测结果 AAAAA
题目名称 [NOI 1998]个人所得税 最终得分 100
用户昵称 Gravatar钨铅 是否通过 通过
代码语言 Pascal 运行时间 0.005 s
提交时间 2013-11-04 22:22:18 内存使用 4.74 MiB
显示代码纯文本
program personaltax;
var a:array[1..50000,1..12]of real;
    i,j,n,x,k:longint;
    ans,t:real;
    ch:char;
    s:string;
function im(x:real):real;
begin
im:=0;
if x>4000 then x:=x-x*0.2 else x:=x-800;
if x<=0 then exit;
if x<=20000 then im:=x*0.2;
if (x>20000)and(x<=50000) then im:=20000*0.2+(x-20000)*0.3;
if x>50000 then im:=20000*0.2+30000*0.3+(x-50000)*0.4;
end;
function pay(x:real):real;
begin
pay:=0;
x:=x-800;
if x<=0 then exit;
if x<=500 then begin
               pay:=x*0.05;
               exit;
               end;
if x<=2000 then begin
                pay:=500*0.05+(x-500)*0.1;
                exit;
                end;
if x<=5000 then begin
                pay:=500*0.05+1500*0.1+(x-2000)*0.15;
                exit;
                end;
if x<=20000 then begin
                 pay:=500*0.05+1500*0.1+3000*0.15+(x-5000)*0.2;
                 exit;
                 end;
if x<=40000 then begin
                 pay:=500*0.05+1500*0.1+3000*0.15+15000*0.2+(x-20000)*0.25;
                 exit;
                 end;
if x<=60000 then begin
                 pay:=500*0.05+1500*0.1+3000*0.15+15000*0.2+20000*0.25+(x-40000)*0.3;
                 exit;
                 end;
if x<=80000 then begin
                 pay:=500*0.05+1500*0.1+3000*0.15+15000*0.2+20000*0.25+20000*0.3+(x-60000)*0.35;
                 exit;
                 end;
if x<=100000 then begin
                  pay:=500*0.05+1500*0.1+3000*0.15+15000*0.2+20000*0.25+20000*0.3+20000*0.35+(x-80000)*0.4;
                  exit;
                  end;
if x>100000 then begin
                 pay:=500*0.05+1500*0.1+3000*0.15+15000*0.2+20000*0.25+20000*0.3+20000*0.35+20000*0.4+(x-100000)*0.45;
                 exit;
                 end;
end;
begin
assign(input,'personaltax.in');
assign(output,'personaltax.out');
reset(input);
rewrite(output);
readln(n);
read(ch);
ans:=0;
while ch<>'#' do begin
                 case ch of
                 'P':begin
                     for j:=1 to 2 do read(ch);
                     read(x);
                     s:='';
                     read(ch);
                     while ch<>'/' do begin
                                      s:=concat(s,ch);
                                      read(ch);
                                      end;
                     val(s,k,j);
                     for j:=1 to 2 do read(ch);
                     readln(t);
                     a[x,k]:=t+a[x,k];
                     end;
                 '#':break;
                 'I':begin
                     for j:=1 to 5 do read(ch);
                     read(x);
                     s:='';
                     while ch<>'/' do begin
                                      s:=concat(s,ch);
                                      read(ch);
                                      end;
                     val(s,k,j);
                     for j:=1 to 2 do read(ch);
                     readln(t);
                     ans:=ans+im(t);
                     end;
                 end;
                 read(ch);
                 end;
for i:=1 to n do
 for j:=1 to 12 do if a[i,j]<>0 then ans:=ans+pay(a[i,j]);
write(ans:0:2);
close(input);
close(output);
end.