HDU 2199 can you solve this equation?

Source: Internet
Author: User
Can you solve this equation?

Time Limit: 2000/1000 MS (Java/others) memory limit: 32768/32768 K (Java/Others)
Total submission (s): 4834 accepted submission (s): 2259

Problem descriptionnow, given the equation 8 * x ^ 4 + 7 * x ^ 3 + 2 * x ^ 2 + 3 * x + 6 = Y, can you find its solution between 0 and 100;
Now please try your lucky.

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 line has a real number y (FABS (y) <= 1e10 );

Outputfor each test case, You shocould just output one real number (accurate up to 4 decimal places), which is the solution of the equation, or "no solution !", If there is no solution for the equation between 0 and 100.

Sample Input

2100-4

Sample output

 
1.6152no solution!

Authorredow

Recommendlcy is a complex question. After the derivation, it is obvious that the derivative is greater than 0 under the condition. There is only one point of intersection between the increase in this interval and the X axis .. Directly judge the value of Y. In binary mode.

 
# Include <stdio. h> double y = 0; double F (Double X) {return 8 * x + 7 * x + 2 * x + 3 * x + 6-y;} int main () {int t; double bop, top, mid, M; M = f (100); scanf ("% d", & T); While (t --) {scanf ("% lf", & Y); If (Y <6 | Y> m) // printf ("no solution! \ N "); else {BOP = 0; Top = 100; while (top-bop> 1e-8) {mid = (top + BOP)/2; If (f (MID) * F (top) <0) BOP = mid; else Top = mid;} printf ("%. 4lf \ n ", mid) ;}} 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.