比赛 20091102 评测结果 WWWWWWWWWW
题目名称 溶液模拟器 最终得分 0
用户昵称 lc 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2009-11-02 11:16:01
显示代码纯文本
program simulator;
 const
   maxn = 10000;
 var
   V,C: array[0..maxn] of extended;
   n:           longint;
   s:           string;



procedure init;

 begin
   readln(V[0],C[0]);
   C[0] :=C[0]/100;
 end;

function Get(l,r:longint):longint;
 var
   num,i: longint;
 begin
   num :=0;
   for i :=l to r do num :=num*10+ord(s[i])-48;
   exit(num);
 end;



procedure main;
 var
   i:   longint;
   p,q:   longint;
   len,pre:     longint;
   Vi,Ci:       extended;
 begin
   readln(N);
   len :=0;  pre :=0;
   for i :=1 to n do begin
       readln(s);
       if pos('P',s) >0
          then begin
               p :=pos(' ',s);
               delete(s,1,p);
               q :=pos(' ',s);
               Vi :=Get(1,q-1);
               Ci :=Get(q+1,length(s));
               Ci :=Ci/100;
               inc(len);
               V[len] :=V[len-1] + Vi;
               C[len] :=(V[len-1]*C[len-1]+Vi*Ci) /(V[len-1]+Vi);
               pre :=len-1;
               writeln(V[len]:0:0,' ',C[len]*100:0:5)
               end
          else begin
               writeln(V[pre]:0:0,' ',C[pre]*100:0:5);
               dec(pre); if pre <0 then pre :=0;
               end;
       end;
 end;



begin
  assign(input,'simulator.in');  reset(input);
  assign(output,'simulator.out'); rewrite(output);
  init;
  main;
  close(input);  close(output);
end.