codevs1038

题目地址: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.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值