Problem Descriptionnow, here is a fuction:
F (x) = 6 * X^7+8*X^6+7*X^3+5*X^2-Y*X (0 <= x <=100)
Can you find the minimum value when x is between 0 and 100.
Inputthe first line of the input contains an integer T (1<=t<=100) which means the number of test cases. Then T-lines follow, each of the line have only one real numbers y. (0 < y <1e10)
Outputjust the minimum value (accurate up to 4 decimal places) while X is between 0 and 100.
Sample Input
2100200
Sample Output
-74.4291-178.8534
#include <stdio.h> #include <math.h>int y;double fun1 (double x) { return 42*pow (x,6) + 48*pow (x,5) + 21*x* x + 10*x-y;} Double fun2 (double x) { return 6*pow (x,7) + 8*pow (x,6) + 7*x*x*x + 5*x*x-y*x;} int main () { int T; scanf ("%d", &t); while (t--) { scanf ("%d", &y); Double Left=0,right=100,middle; while (right-left>=1e-10) { middle= (left+right)/2; if (fun1 (middle) >0) Right=middle; else left=middle; } printf ("%.4lf\n", fun2 (left)); } return 0;}
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Strange fuction HDU 2899 "two minutes"