题目地址:http://codevs.cn/problem/1038/
分析:
盛金公式
代码:
uses math;
var
a,b,c,d,M,N,t,x1,x2,x3:float;
begin
readln(a,b,c,d);
M:=b*b-3*a*c;
N:=b*c-9*a*d;
t:=(2*M*b-3*a*N)/(2*sqrt(M*M*M));
t:=arccos(t);
t:=t/3;
x1:=(-b-2*sqrt(M)*cos(t))/(3*a);
x2:=(-b+sqrt(M)*(cos(t)+1.73205*sin(t)))/(3*a);
x3:=(-b+sqrt(M)*(cos(t)-1.73205*sin(t)))/(3*a);
if x1<x2 then if x1<x3 then
begin
if x2>x3 then
write(x1:0:2,' ',x3:0:2,' ',x2:0:2)
else write(x1:0:2,' ',x2:0:2,' ',x3:0:2);
end;
if x2<x1 then if x2<x3 then
begin
if x3>x1 then
write(x2:0:2,' ',x1:0:2,' ',x3:0:2)
else write(x2:0:2,' ',x3:0:2,' ',x1:0:2);
end;
if x3<x2 then if x3<x1 then
begin
if x2>x1 then
write(x3:0:2,' ',x1:0:2,' ',x2:0:2)
else write(x3:0:2,' ',x2:0:2,' ',x1:0:2);
end;
end.
uses math;
var
a,b,c,d,M,N,t,x1,x2,x3:float;
begin
readln(a,b,c,d);
M:=b*b-3*a*c;
N:=b*c-9*a*d;
t:=(2*M*b-3*a*N)/(2*sqrt(M*M*M));
t:=arccos(t);
t:=t/3;
x1:=(-b-2*sqrt(M)*cos(t))/(3*a);
x2:=(-b+sqrt(M)*(cos(t)+1.73205*sin(t)))/(3*a);
x3:=(-b+sqrt(M)*(cos(t)-1.73205*sin(t)))/(3*a);
if x1<x2 then if x1<x3 then
begin
if x2>x3 then
write(x1:0:2,' ',x3:0:2,' ',x2:0:2)
else write(x1:0:2,' ',x2:0:2,' ',x3:0:2);
end;
if x2<x1 then if x2<x3 then
begin
if x3>x1 then
write(x2:0:2,' ',x1:0:2,' ',x3:0:2)
else write(x2:0:2,' ',x3:0:2,' ',x1:0:2);
end;
if x3<x2 then if x3<x1 then
begin
if x2>x1 then
write(x3:0:2,' ',x1:0:2,' ',x2:0:2)
else write(x3:0:2,' ',x2:0:2,' ',x1:0:2);
end;
end.