HDU-2199 (search_bin-precision)

Source: Internet
Author: User

This is, for the first time I saw such a fun thing...

I have never considered such a problem before ,,,

Incorrect precision processing. The question is coming soon. Well, this is really a test of people's patience. Well, next time, will the EPS be opened a little less?

As I have just proved, the first time I started it was 1e-8, obviously not enough, but less than 1e-13 .. hey hey. so be sure to pay attention to it in the future. Open it hard ....

Haha, because the smaller you open, the closer you get to the answer...

Have a long time and wisdom.

Paste the Code:

# Include <stdio. h> # include <string. h> # include <stdlib. h> # include <math. h> // the incremental function is obtained because the derivative of the function is 0-constant and 0; // the minimum value is 6 because it is an incremental function; none of the values smaller than 6; const double EPS = 1e-15; double F (Double X) {return 8 * POW (x, 4) + 7 * POW (x, 3) + 2 * POW (x, 2) + 3 * x + 6;} int main () {int t; scanf ("% d", & T ); while (t --) {Double Y; scanf ("% lf", & Y); If (Y <6 | Y> F (100.0) printf ("no solution! \ N "); else {double L = 0, r = 100, mid; while (L + EPS <= r) {mid = (L + r)/2; double P = f (MID); If (FABS (p-y) <= 1e-5) {printf ("%. 4lf \ n ", mid); break;} else if (P <Y) L = mid; elser = mid;} If (L + EPS> r) printf ("no solution! \ N ") ;}} return 0 ;}

 

 

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.