0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-27 22:56:27 +00:00

P1024 一元三次方程求解

R38992526
This commit is contained in:
Baoshuo Ren 2020-09-28 21:42:12 +08:00 committed by Baoshuo Ren
parent 7b7d7241fe
commit b4f39098f2
Signed by: baoshuo
GPG Key ID: 70F90A673FB1AB68

28
problem/P1024/P1024.cpp Normal file
View File

@ -0,0 +1,28 @@
// R38992526
#include <bits/stdc++.h>
using namespace std;
double a, b, c, d;
int cnt;
double fc(double x) {
return a * x * x * x + b * x * x + c * x + d;
}
int main() {
scanf("%lf%lf%lf%lf", &a, &b, &c, &d);
for (double i = -100.00; i <= 100.00; i += 0.001) {
double l = i, r = i + 0.001;
if (fc(l) * fc(r) < 0) {
printf("%.2f ", l);
cnt++;
}
if (cnt == 3) {
printf("\n");
break;
}
}
return 0;
}