记录编号 |
123989 |
评测结果 |
AAAAA |
题目名称 |
[NOIP 2000PJ]计算器的改良 |
最终得分 |
100 |
用户昵称 |
FoolMike |
是否通过 |
通过 |
代码语言 |
Pascal |
运行时间 |
0.001 s |
提交时间 |
2014-10-01 21:57:12 |
内存使用 |
0.17 MiB |
显示代码纯文本
var
s:ansistring;
ch,fh:char;
a,b,c,w,xs,xs1,xs2,l:longint;
x:real;
begin
assign(input,'computer.in');
reset(input);
assign(output,'computer.out');
rewrite(output);
readln(s);
s:=s+'.';
c:=1;
while (s[c]>'z')or(s[c]<'a') do inc(c);
ch:=s[c];
if (s[1]='+')or(s[1]='-') then
begin
c:=2;
fh:=s[1];
end
else
begin
c:=1;
fh:='+';
end;
a:=0;xs1:=0;xs2:=0;
repeat
while (s[c]<>'+')and(s[c]<>'-')and(s[c]<>'=')and(s[c]<>'.') do inc(c);
w:=c-1;
if s[c-1]=ch then dec(w);
{writeln(w);}
l:=1;xs:=0;
while (w<>0)and(s[w]>='0')and(s[w]<='9') do
begin
xs:=xs+(ord(s[w])-48)*l;
l:=l*10;
dec(w);
end;
if (xs=0)and(s[c-1]=ch) then xs:=1;
{write(fh,' ');}
if fh='-' then xs:=-xs;
if a=0 then
if s[c-1]=ch then xs1:=xs1+xs else xs2:=xs2-xs
else
if s[c-1]=ch then xs1:=xs1-xs else xs2:=xs2+xs;
if s[c]='.' then break;
if s[c]='=' then a:=1;
fh:=s[c];
inc(c);
{writeln(xs,' ',xs1,' ',xs2);}
until s[c]='.';
x:=xs2/xs1;
b:=abs(round(x*1000) mod 1000);
write(ch,'=',trunc(x),'.');
if b<10 then writeln('00',b);
if (100>b)and(b>=10) then writeln('0',b);
if b>=100 then writeln(b);
close(input);close(output);
end.