先用不定积分求出那个v=t
2的,s=t
3/3。然后列一个方程求根了。三次方程有求根公式,但是偶还米学到,所以就用二分叠代来求这个根了~
#include
<
iostream
>
#include
<
iomanip
>
using
namespace
std;
![None.gif](/Images/OutliningIndicators/None.gif)
double
f(
double
a,
double
k,
double
x);
int
main()
![ExpandedBlockStart.gif](/Images/OutliningIndicators/ExpandedBlockStart.gif)
{
double min,max,a,b,t,i;
while(cin>>a>>b)
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
min = 0.0;
max = 1e+10;
while(max - min > 1e-5)
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
i = (max+min) / 2.0;
t = f(a,b,i);
if(t - 1e-100 > 0)
max = i;
else if(t + 1e-100 < 0)
min = i;
else
min = max = i;
}
cout<<setiosflags(ios::fixed)<<setprecision(4)<<min<<endl;
}
return 0;
}
double
f(
double
a,
double
k,
double
x)
![ExpandedBlockStart.gif](/Images/OutliningIndicators/ExpandedBlockStart.gif)
{return ((x-k)*(x-k)*(x-k)/3.0 - a*x*x/2.0);}