Bridge

A suspension bridge suspends the roadway from huge main cables, which extend from one end of the bridge to the other. These cables rest on top of high towers and are secured at each end by anchorages. The towers enable the main cables to be draped over long distances.

Suppose that the maximum distance between two neighboring towers is D <tex2html_verbatim_mark>, and that the distance from the top of a tower to the roadway is H <tex2html_verbatim_mark>. Also suppose that the shape of a cable between any two neighboring towers is the same symmetric parabola (as shown in the figure). Now given B <tex2html_verbatim_mark>, the length of the bridge and L <tex2html_verbatim_mark>, the total length of the cables, you are asked to calculate the distance between the roadway and the lowest point of the cable, with minimum number of towers built (Assume that there are always two towers built at the two ends of a bridge).

<tex2html_verbatim_mark>

Input

Standard input will contain multiple test cases. The first line of the input is a single integer T <tex2html_verbatim_mark>(1T10) <tex2html_verbatim_mark>which is the number of test cases. T <tex2html_verbatim_mark>test cases follow, each preceded by a single blank line.

For each test case, 4 positive integers are given on a single line.

D<tex2html_verbatim_mark>
- the maximum distance between two neighboring towers;
H<tex2html_verbatim_mark>
- the distance from the top of a tower to the roadway;
B<tex2html_verbatim_mark>
- the length of the bridge; and
L<tex2html_verbatim_mark>
- the total length of the cables.

It is guaranteed that BL <tex2html_verbatim_mark>. The cable will always be above the roadway.

Output

Results should be directed to standard output. Start each case with "Case # <tex2html_verbatim_mark>:" on a single line, where # <tex2html_verbatim_mark>is the case number starting from 1. Two consecutive cases should be separated by a single blank line. No blank line should be produced after the last test case.

For each test case, print the distance between the roadway and the lowest point of the cable, as is described in the problem. The value must be accurate up to two decimal places.

Sample Input

2

20 101 400 4042

1 2 3 4

Sample Output

Case 1:
1.00 Case 2:
1.60
 //总算遇到精度问题啦,吃一堑长一智了!!!

 #include<stdio.h>
#include<math.h>
#define eps 1e-10//这题居然卡精度的啊!!!!!哭死啦!!!!1e-8都过不了啊!!! int dcmp(double a)
{
if(fabs(a)<eps)return ;
if(a>)return ;
else return -;
} int main()
{
int ca,T,i,j;
int cnt,B,D,H,L;
scanf("%d",&T);
for(ca=;ca<=T;ca++)
{
double mid,d,l;
scanf("%d%d%d%d",&D,&H,&B,&L);
cnt=B/D;
if(cnt*D!=B)
cnt++;
d=1.0*B/cnt/2.0;
l=1.0*L/cnt/2.0;
double ll,rr;
ll=0.0,rr=1000000.0;
while(rr-ll>eps)
{
mid=(ll+rr)/2.0;
double tmp=sqrt(+1.0/4.0/mid/mid/d/d);
double sss=mid*d*d*tmp+1.0/4.0/mid*(log(*mid*d*(tmp+)));
if(dcmp(sss-l)==)
rr=mid-eps;
else
ll=mid+eps;
}
double k=mid;
double y=k*d*d;
double ans=1.0*H-y;
if(ans<)ans=;//可有可无,数据中的绳子都是伸直的!!
printf("Case %d:\n",ca);
printf("%.2f\n",ans);
if(ca<T)printf("\n");
}
}

UVAlive 3485 Bridge(抛物线弧长积分)的更多相关文章

  1. UVA 3485 Bridge

    题目大意 你的任务是修建一座大桥.桥上等距地摆放着若干个塔,塔高为H,宽度忽略不计.相邻两座塔之间的距离不能超过D.塔之间的绳索形成全等的对称抛物线.桥长度为B,绳索总长为L,如下图所示求建最少的塔时 ...

  2. HDU 4752 Polygon(抛物线长度积分)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4752 题意:给出一个抛物线和一个简单多边形.求抛物线在多边形内部的长度. 思路:首先求出多边形所有边和 ...

  3. LA 3485 Bridge

    自适应辛普森公式模板. #include<algorithm> #include<iostream> #include<cstring> #include<c ...

  4. LA 3485 (积分 辛普森自适应法) Bridge

    桥的间隔数为n = ceil(B/D),每段绳子的长度为L / n,相邻两塔之间的距离为 B / n 主要问题还是在于已知抛物线的开口宽度w 和 抛物线的高度h 求抛物线的长度 弧长积分公式为: 设抛 ...

  5. 曲线参数化的Javascript实现(代码篇)

    在曲线参数化的Javascript实现(理论篇)中推出了曲线弧长积分的公式,以及用二分法通过弧长s来查找样条曲线上对应的u,再求Q(u)的值.弧长积分函数如下: ,其中-----公式1 Simpson ...

  6. .Uva&LA部分题目代码

    1.LA 5694 Adding New Machine 关键词:数据结构,线段树,扫描线(FIFO) #include <algorithm> #include <cstdio&g ...

  7. uva 1356 Bridge ( 辛普森积分 )

    uva 1356 Bridge ( 辛普森积分 ) 不要问我辛普森怎么来的,其实我也不知道... #include<stdio.h> #include<math.h> #inc ...

  8. HDU_1071——积分求面积,抛物线顶点公式

    Problem Description Ignatius bought a land last week, but he didn't know the area of the land becaus ...

  9. UVA 1356 - Bridge(自适应辛普森)

    UVA 1356 - Bridge option=com_onlinejudge&Itemid=8&page=show_problem&category=493&pro ...

随机推荐

  1. 企业级技术解决方案:hbase+es

    1:需求: 解决海量数据的存储,并且能够实现海量数据的秒级查询 Hbase是典型的nosql,是一种构建在HDFS之上的分布式.面向列的存储系统,在需要的时候可以进行实时的大规模数据集的读写操作:但是 ...

  2. 取得所有网卡的MAC地址,包括禁用的

    先在nuget包中添加System.Management.Automation引用. 然后下面就是代码了. using System;using System.Collections.ObjectMo ...

  3. optistruct线性求解一次二次单元应力位移比较

    通过分析比较10mm.5mm.3mm.1mm的网格模型, 网格越细密: 位移与应力均趋于恒定值(收敛): 一次与二次单元的应力区域一致: 一次与二次单元的位移相差11.3%,一次单元的位移小. 所用的 ...

  4. springSecurity总结

    springSecurity总结: 一.Spring security框架简介   1.简介           一个能够为基于Spring的企业应用系统提供声明式的安全訪问控制解决方式的安全框架(简 ...

  5. (转)flexpaper 参数

    本文转载自:http://blog.csdn.net/z69183787/article/details/18659913 Flexpaper可能用到如下参数   SwfFile (String) 需 ...

  6. border-radius 如何计算

    1.使用px: 圆的半径是那个px值大小 用这个圆放到div的角上去切割div 2.使用%: 如果长度和宽度一样 圆的半径是长度乘这个百分比得到的结果 如果长度和宽度不一样 产生的效果是宽高乘以百分数 ...

  7. Docker image 和 volume 的关系

    image :镜像 虚拟机容器需要加载image才能运行,镜像中打包了构建好服务的运行环境. Docker images are the basis of containers. An Image i ...

  8. DEDECMS首页,列表页调用自定义图片字段,只显示图片地址

    第一步:将自定义字段“图片”类型改为“图片(仅地址)”类型. 第二部:在{dede:arclist row='1' addfields='stu' titlelen='24' orderby='pub ...

  9. Vue的生命周期(在其他地方看到一份非常好又详细的详解)

    链接地址:https://segmentfault.com/a/1190000011381906 首先,每个Vue实例在被创建之前都要经过一系列的初始化过程,这个过程就是vue的生命周期.首先看一张图 ...

  10. HashMap为什么在多线程下会让cpu100%

    首先HashMap并不是sun公司多线程提供的集合,很多时候我们的程序是一个主线程,用了hashmap并没有什么问题,但是在多线程下会出现问题. hashmap是一个哈希表,存储的数据结构也可以是一个 ...