UVAlive 3485 Bridge(抛物线弧长积分)
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).

Input
Standard input will contain multiple test cases. The first line of the input is a single integer T <tex2html_verbatim_mark>(1T
10) <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(抛物线弧长积分)的更多相关文章
- UVA 3485 Bridge
题目大意 你的任务是修建一座大桥.桥上等距地摆放着若干个塔,塔高为H,宽度忽略不计.相邻两座塔之间的距离不能超过D.塔之间的绳索形成全等的对称抛物线.桥长度为B,绳索总长为L,如下图所示求建最少的塔时 ...
- HDU 4752 Polygon(抛物线长度积分)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4752 题意:给出一个抛物线和一个简单多边形.求抛物线在多边形内部的长度. 思路:首先求出多边形所有边和 ...
- LA 3485 Bridge
自适应辛普森公式模板. #include<algorithm> #include<iostream> #include<cstring> #include<c ...
- LA 3485 (积分 辛普森自适应法) Bridge
桥的间隔数为n = ceil(B/D),每段绳子的长度为L / n,相邻两塔之间的距离为 B / n 主要问题还是在于已知抛物线的开口宽度w 和 抛物线的高度h 求抛物线的长度 弧长积分公式为: 设抛 ...
- 曲线参数化的Javascript实现(代码篇)
在曲线参数化的Javascript实现(理论篇)中推出了曲线弧长积分的公式,以及用二分法通过弧长s来查找样条曲线上对应的u,再求Q(u)的值.弧长积分函数如下: ,其中-----公式1 Simpson ...
- .Uva&LA部分题目代码
1.LA 5694 Adding New Machine 关键词:数据结构,线段树,扫描线(FIFO) #include <algorithm> #include <cstdio&g ...
- uva 1356 Bridge ( 辛普森积分 )
uva 1356 Bridge ( 辛普森积分 ) 不要问我辛普森怎么来的,其实我也不知道... #include<stdio.h> #include<math.h> #inc ...
- HDU_1071——积分求面积,抛物线顶点公式
Problem Description Ignatius bought a land last week, but he didn't know the area of the land becaus ...
- UVA 1356 - Bridge(自适应辛普森)
UVA 1356 - Bridge option=com_onlinejudge&Itemid=8&page=show_problem&category=493&pro ...
随机推荐
- jq和js用法:入口写法
jq和js入口写法demo: <!DOCTYPE html> <html lang="en"> <head> <meta charset= ...
- SQL Server函数大全(三)----Union与Union All的区别
如果我们需要将两个select语句的结果作为一个整体显示出来,我们就需要用到union或者union all关键字.union(或称为联合)的作用是将多个结果合并在一起显示出来. union和unio ...
- Android传感器系统架构【转】
本文转载自:http://blog.csdn.net/qianjin0703/article/details/5942579 版权声明:本文为博主原创文章,未经博主允许不得转载. 1. 体系结构 2. ...
- 查看在linux中下载的图片
1.安装 yum install lrzsz -y 2.找到文件所在的位置选中之后 3.点击那个蓝色的框框里面有一个 用ZMODEM下载 4.选择要保存的位置就可以查看了
- winform最小化及添加右键
private void PrintService_SizeChanged(object sender, EventArgs e) { if (this.WindowState == FormWind ...
- netstat和ps
ps是查看进程, 主要是针对本机的, 进程活动, 更多的是关注性能, 关注对机器 资源的使用清况 netstat是查看网络状态, 主要是针对网络的.是查看网络上, 对内网 外网的活动情况, 更多的是关 ...
- 架构-层-DAL:DAL
ylbtech-架构-层-DAL:DAL DAL是数据访问层的英文缩写,即为数据访问层(Data Access Layer).其功能主要是负责数据库的访问.简单地说就是实现对数据表的Select(查询 ...
- Sails.js中文文档,Sails中文文档
Sails.js中文文档 http://sailsdoc.swift.ren/ Sails.js是一个Web框架,可以于轻松构建自定义,企业级Node.js Apps.它在设计上类似于像Ruby ...
- 阶段1 语言基础+高级_1-3-Java语言高级_06-File类与IO流_05 IO字符流_5_flush方法和close方法的区别
flush之后,还可以继续使用流写文件
- docker远程访问TLS证书认证shell
docker开启远程访问端口,防止非法访问 配置证书认证 配置防火墙或安全策略 #!/bin/bash # docker.tls.sh # 环境centos 7 ,root # 创建 Docker T ...