链接
https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=4102
题解
吐槽:绳索竟然是抛物线??
这题就是枚举高度然后做第一类曲线积分…没了
代码
//adoptive simpson's rule
#include <bits/stdc++.h>
#define eps 1e-8
#define sqr(x) ((x)*(x))
using namespace std;
double a;
double F(double x)
{
return sqrt(1+sqr(2*a*x));
}
double simpson(double l, double r)
{
return (F(l)+F(r)+4.0*F((l+r)/2.0))*(r-l)/6.0;
}
double asr(double l, double r, double Eps, double A)
{
double mid=(l+r)/2, L=simpson(l,mid), R=simpson(mid,r);
if(fabs(L+R-A)<15.0*Eps)return L+R+(L+R-A)/15.0;
return asr(l,mid,Eps/2,L) + asr(mid,r,Eps/2,R);
}
double intergral(double l, double r)
{
return asr(l,r,eps,simpson(l,r));
}
int read(int x=0)
{
char c, f=1;
for(c=getchar();!isdigit(c);c=getchar())if(c=='-')f=-f;
for(;isdigit(c);c=getchar())x=x*10+c-48;
return f*x;
}
int main()
{
int T=read(), kase=0;
double cnt, d, l, r, mid, D, H, B, L;
while(T--)
{
D=read(), H=read(), B=read(), L=read();
cnt = ceil(B/D);
d = B/cnt;
l=0, r=L/cnt, mid=(l+r)/2;
for(int i=1;i<=100;i++)
{
a=4*mid/d/d;
fflush(stdout);
if(intergral(-d/2,d/2)<L/cnt)l=mid;
else r=mid;
mid=(l+r)/2;
}
printf("Case %d:\n%.2lf\n",++kase,H-mid);
if(T)printf("\n");
}
return 0;
}