Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 2091 Accepted Submission(s): 1053
#include <set>
#include <map>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <cctype>
#include <cstring>
#include <sstream>
#include <fstream>
#include <cstdlib>
#include <cassert>
#include <iostream>
#include <algorithm>
using namespace std;
//Constant Declaration
/*--------------------------*/
//#define LL long long
#define LL __int64
const int M=1000000;
const int INF=1<<30;
const double EPS = 1e-11;
const double PI = acos(-1.0);
/*--------------------------*/
// some essential funtion
/*----------------------------------*/
void Swap(int &a,int &b){ int t=a;a=b;b=t; }
int Max(int a,int b){ return a>b?a:b; }
int Min(int a,int b){ return a<b?a:b; }
int Gcd(int a,int b){ while(b){b ^= a ^=b ^= a %= b;} return a; }
/*----------------------------------*/
//for (i = 0; i < n; i++)
/*----------------------------------*/
#define F(x) (8*pow(x,4) + 7*pow(x,3) + 2*pow(x,2) + 3*x + 6 - y)
double y;
int main()
{
//freopen("in.txt","r",stdin);
//freopen("out.txt","w",stdout);
int t, case1 = 0;
scanf("%d", &t);
int n, m;
int i, j;
//scanf("%d%d", &n, &m);
while (t--)
{
scanf("%lf", &y);
if (F(0.0) * F(100.0) > 0)
{
puts("No solution!");
}
else
{
double l = 0, r = 100;
if (F(l) == 0)
{
printf("%.4lf", 0);
goto end;
}
if (F(r) == 0)
{
printf("%.4lf", 100);
goto end;
}
double min;
while (r - l > EPS)
{
min = (l + r) / 2;
if (F(min) == 0)
{
goto end;
}
if (F(l) * F(min) < 0)
{
r = min;
}
else
{
l = min;//写成l = min + 1就错
}
}
end :
printf("%.4lf\n", min);
}
}
return 0;
}