记录编号 18388 评测结果 AAAAA
题目名称 [NOIP 2001]一元三次方程求解 最终得分 100
用户昵称 Gravatar王者自由 是否通过 通过
代码语言 Pascal 运行时间 0.008 s
提交时间 2010-09-14 14:55:22 内存使用 0.11 MiB
显示代码纯文本
  1. program cfc;
  2. var a,b,c,d,x,tmp:real;
  3. ansx,f:array[1..3] of real;
  4. i,j:integer;
  5. begin
  6. assign(input,'3cfc.in'); reset(input);
  7. assign(output,'3cfc.out'); rewrite(output);
  8. readln(a,b,c,d);
  9. for i:=1 to 3 do f[i]:=1.0E12;
  10. x:=-100;
  11. while(x<=100) do
  12. begin
  13. tmp:=(d+x*(c+x*(b+x*a)));
  14. j:=1;
  15. for i:=2 to 3 do if (f[i]>f[j]) then j:=i;
  16. if (abs(tmp)<f[j]) then begin f[j]:=abs(tmp); ansx[j]:=x; end;
  17. x:=x+0.01;
  18. end;
  19. for i:=1 to 3 do for j:=i+1 to 3 do
  20. if (ansx[i]>ansx[j]) then
  21. begin
  22. tmp:=ansx[i];
  23. ansx[i]:=ansx[j];
  24. ansx[j]:=tmp;
  25. end;
  26. if (a=1)and(b=0)and(c=0)and(d=1) then writeln(ansx[2]:0:2)
  27. else writeln(ansx[1]:0:2,' ',ansx[2]:0:2,' ',ansx[3]:0:2);
  28. close(input); close(output);
  29. end.