2199 Can you solve this equation?
Problem Description
Now,given the equation 8x^4 + 7x^3 + 2x^2 + 3x + 6 == Y,can you find its solution between 0 and 100;
Now please try your lucky.
Input
The 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);
Output
For each test case, you should 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
1 | 2 |
Sample Output
1 | 1.6152 |
Suggest Answer
一开始是想着用暴力做的,因为x的范围是0-100,用暴力做得不到正确答案,因为答案出来都是浮点数,暴力枚举的都是整数.看看题目的函数8x^4 + 7x^3 + 2x^2 + 3x + 6 == Y,是一个单调递增的函数,所以可以用二分来做.
1 | import java.util.*; |