50pts
查看原帖
50pts
1079728
xcc_114楼主2024/10/22 22:07
#include<bits/stdc++.h>

using namespace std;

double a, b, c, d;

double f(double x){
	return a * pow(x, 3) + b * x * x + c * x + d;
}

int main(){
	scanf("%lf%lf%lf%lf", &a, &b, &c, &d);
	for(double l = -100; l <= 100; l++){
		double r = l + 1;
		if(!f(l)) printf("%.2lf ", l);
		if(f(l) * f(r) < 0){
			while(r - l >= 0.001){
				double m = (l + r) / 2;
				if(f(l) * f(m) < 0) r = m;
				else l = m;
			}
		}
	}
	return 0;
}
2024/10/22 22:07
加载中...