传送门:2199
传送门:2899
2199代码:
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
double y;
double solve(double xx)
{return 8*xx*xx*xx*xx+7*xx*xx*xx+2*xx*xx+3*xx+6;}
int main()
{
int t;scanf("%d",&t);
while (t--)
{
scanf("%lf",&y);
if (y<solve(0)||y>solve(100))
printf("No solution!\n");
else
{
double ans=-1,op,l=0,r=100,m;
while (r-l>=0.00000001)
{
m=(r+l)/2;
op=solve(m);
if (op>=y)
{
ans=m;
r=m;
}
else
l=m;
}
printf("%.4lf\n",ans);
}
}
return 0;
}
2899代码:
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
double y;
double solve(double xx)
{return 42*pow(xx,6)+48*pow(xx,5)+21*pow(xx,2)+10*xx;}
int main()
{
int t;scanf("%d",&t);
while (t--)
{
scanf("%lf",&y);
double ans=-1,op,l=0,r=100,m;
while (r-l>=0.00000001)
{
m=(r+l)/2;
op=solve(m);
if (op>=y)
{
ans=m;
r=m;
}
else
l=m;
}
ans=(6*pow(ans,7)+8*pow(ans,6)+7*pow(ans,3)+5*ans*ans-y*ans);
printf("%.4lf\n",ans);
}
return 0;
}