Hdu 2899 Simple three points

Source: Internet
Author: User

The third part is the further determination of the interval value on the basis of the two points first divides the interval into three points and then updates the left and right interval values


#include <stdio.h> #include <string.h> #include <iostream>using namespaceStd;#define EXP 1e-6DoubleY; Double Pow (double A ,int B ) {  int I; Double X=1;  for (I=1;I<=B;I++) {X*=A; }  return X;} Double F (double X ) {  return 6*Pow(X,7)+8*Pow(X,6)+7*Pow(X,3)+5*Pow(X,2)-Y*X; ;} int Main () {  int T,I,J;scanf("%d",&T);  while (T--) {scanf("%LF",&Y); Double Row=0,Right= -;  while (Right-Row>Exp ) {  double Mid1=(2*Row+Right)/3; Double Mid2=(Row+2*Right)/3; if (F(Mid1) >F(Mid2))Row=Mid1; Else Right=Mid2; }Printf("%.4lf\n",F(Row)); }  return 0;}

Hdu 2899 Simple three points

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.