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 ...
随机推荐
- jquery attr()方法获取input的checked属性问题
问题:经常使用jQuery插件的attr方法获取checked属性值,获取的值的大小为未定义,此时可以用prop方法获取其真实值,下面介绍这两种方法的区别: 1.通过prop方法获取checked属性 ...
- php WebSocket 简单实现demo
WebSocket 是 HTML5 开始提供的一种在单个 TCP 连接上进行全双工通讯的协议. WebSocket 使得客户端和服务器之间的数据交换变得更加简单,允许服务端主动向客户端推送数据. 在 ...
- JavaScript-Templates
https://github.com/blueimp/JavaScript-Templates https://blueimp.github.io/JavaScript-Templates/ http ...
- Mac基本配置
相关操作 配置文件 java 下载jdk-12.0.1_osx-x64_bin.dmg 配置环境变量 #配置java JAVA_HOME=/Library/Java/JavaVirtualMachin ...
- 【MM系列】SAP MM模块-移动类型全部列表
公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[MM系列]SAP MM模块-移动类型全部列表 ...
- data plugin for vs2019
Reporting Service projects for VS 2019https://marketplace.visualstudio.com/items?itemName=ProBITools ...
- 分享一篇Linux系统使用Tomcat服务时交互式修改server.xml中端口号的shell脚本
#!/bin/bash echo -e '\n' echo "***********************************" port1=`grep -r "s ...
- linux command --- terminal common commands
switch to root : sudo su.su root.sudo -s switch to users : su god(user name) set root password : sud ...
- [Python3 填坑] 002 isdecimal() 与 isdigit() 的区别 + isnumeric() 的补充
目录 1. print( 坑的信息 ) 2. isdecimal() 官方文档 3. isdigit() 官方文档 4. 举例 (1) 先说结论 (2) 示例 5. 补充 isnumeric() (1 ...
- [Python3] 015 冰冻集合的内置方法
目录 0. 前言 英文名 元素要求 使用限制 返回 方法数量 1. 如何查看 frozenset() 的内置方法 2. 少废话,上例子 2.1 copy() 2.2 difference() 2.3 ...