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).
<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>(1
T
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 B
L <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 ...
 
随机推荐
- css内容过长显示省略号的几种解决方法
			
单行文本(方法一): 语法: text-overflow : clip | ellipsis 参数: clip : 不显示省略标记(...),而是简单的裁切 (clip这个参数是不常用的!) elli ...
 - 常用的HTML标记整理
			
文章CSDN地址:https://blog.csdn.net/Ght1997... 文章GitHub地址:https://github.com/ght1997012...文章segmentfault地 ...
 - 开源认证组件汇总  Kerberos和CAS
			
一.Kerberos 1.Kerberos原理和工作机制 概述:Kerberos的工作围绕着票据展开,票据类似于人的驾驶证,驾驶证标识了人的信息,以及其可以驾驶的车辆等级. 1.1 客户机初始验证 ...
 - POJ2395 Out of Hay(求最小生成树中最大的边权,Kruskal)
			
POJ2395 Out of Hay 寻找最小生成树中最大的边权. 使用 Kruskal 求解,即求选取的第 \(n-1\) 条合法边. 时间复杂度为 \(O(e\log e)\) . #includ ...
 - TypeScript快速笔记(二)
			
1) TypeScript中的判断语句,可以使用非0值代表true.如: function add1(a: number, b?:number): number{ // 注意b是可选参数 consol ...
 - 7月清北学(zao)堂系列
			
7.13:模拟,贪心(贪心题大赏),考试 7.14:分治,分块,搜索(大法师大法好),数论 7.15:数据结构(树状数组,线段树,),ST表,树上倍增求LCA 7.16:图论题大赏(分层建图神马的), ...
 - linux设置开机启动程序?
			
/etc/rc.d/init.d 是 /etc/init.d的目标链接. 如果/etc/rc.d下面没有 rc.local脚本文件, 则需要 手动创建: 而 /etc/bashrc 是在登陆bash ...
 - VMware 虚拟化编程(10) — VMware 数据块修改跟踪技术 CBT
			
目录 目录 前文列表 数据块修改跟踪技术 CBT 为虚拟机开启 CBT CBT 修改数据块偏移量获取函数 QueryChangedDiskAreas changeId 一个 QueryChangedD ...
 - set_index()与reset_index()函数
			
一 set_index()函数 1 主要是理解drop和append参数,注意与reset_index()参数的不同. import pandas as pd df = pd.DataFrame({' ...
 - Jmeter之JDBC--Mysql
			
一.添加JDBC Connection Configuration控件 界面显示如下: 配置说明: 1.名称:标识 2.注释:备注信息 3.Variable Name:定义的变量名,供后续调用: 4. ...