Strange fuctiontime limit:2000/1000 MS (java/others) Memory limit:32768/32768 K (java/others) total submission (s): 5 933 Accepted Submission (s): 4194Problem Descriptionnow, here is a fuction:
Three minutes and two points can be, the derivative is monotonous, after the derivation of the second score AC code
1#include"iostream"2#include"algorithm"3#include"Cstdio"4#include"CString"5#include"Cmath"6 #defineMax (A, b) a>b?a:b7 #defineMin (A, b) a<b?a:b8 #defineMX 10000 + 509 using namespacestd;Ten Doubley; One A DoubleFDoublex) {//derivative - return the*pow (x,6)+ -*pow (x,5)+ +*x*x+Ten*x-y;//F (x) = 6 * X^7+8*X^6+7*X^3+5*X^2-Y*X (0 <= x <=100) - } the - DoubleFDoublex) { - return 6* POW (x,7)+8*pow (x,6)+7*x*x*x+5*x*x-y*x;//F (x) = 6 * X^7+8*X^6+7*X^3+5*X^2-Y*X (0 <= x <=100) - } + - intMain () { + intT; A while(cin>>T) { at for(intqq=0; qq<t; qq++) { -Cin>>y; - if(F (0) >0) { -printf"%.4f\n"F0)); -}Else if(F ( -) <0) { -printf"%.4f\n"F -)); in}Else { - DoubleL=0;//0 L R to DoubleR= -;// ------------------------- + Doublemid; - while(r-l>1e-8) { theMid= (r+l)/2.0; * if(f (Mid) >0) { $R=mid;Panax Notoginseng}Else { -L=mid; the } + } Aprintf"%.4f\n", F (mid)); the } + } - } $ return 0; $}
View Code
Acm:hdu 2899 Strange fuction Problem Solving report-two points, three points