题目大意:给6个系数,问是否存在X使得等式成立
思路:二分。。。。
#include <stdio.h> #include <math.h> #define EEE 2.71828182845953581496 int p, q, r, s, t, u; double v(double x) { return (p*pow(EEE,-x)+q*sin(x)+r*cos(x)+s*tan(x)+t*x*x); } double f(double x,double z, double y) { double mid; while((y-z)>1e-10) { mid=(z+y)/2; if(v(mid)>x) z=mid+1e-10; else y=mid-1e-10; } return mid; } int main() { while(~scanf("%d%d%d%d%d%d", &p, &q, &r, &s, &t, &u)) { if(v(0)<-u||v(1)>-u) printf("No solution "); else printf("%.4lf ", f(-u,0,1)); } return 0; }