UOJ Logo

NOI.AC

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#206381#1745. 一元三次方程求解shawn1001ms1244kbC++403b2024-07-22 17:30:392024-07-22 20:00:06

answer

#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
   double a,b,c,d;
   scanf("%lf%lf%lf%lf",&a,&b,&c,&d);
   for(double i=-100;i<=100;i+=0.001)
   {
      double j=i+0.001;
      double y1=a*i*i*i+b*i*i+c*i+d;
      double y2=a*j*j*j+b*j*j+c*j+d;
      if(y1>=0&&y2<=0||y1<=0&&y2>=0)
      {
         double x=(i+j)/2;
         printf("%.2lf ",x);
      }
   }
}

详细

小提示:点击横条可展开更详细的信息

Test #1:

score: 25
Accepted
time: 0ms
memory: 1240kb

input:

1 -2 -1 2

output:

-1.00 1.00 2.00 

result:

ok single line: '-1.00 1.00 2.00 '

Test #2:

score: 25
Accepted
time: 1ms
memory: 1244kb

input:

1 -4.65 2.25 1.4

output:

-0.35 1.00 4.00 

result:

ok single line: '-0.35 1.00 4.00 '

Test #3:

score: 25
Accepted
time: 0ms
memory: 1240kb

input:

1 10 -1 -10

output:

-10.00 -1.00 1.00 

result:

ok single line: '-10.00 -1.00 1.00 '

Test #4:

score: 25
Accepted
time: 0ms
memory: 1240kb

input:

1 -1.8 -8.59 -0.84

output:

-2.10 -0.10 4.00 

result:

ok single line: '-2.10 -0.10 4.00 '