POJ 1905 Expanding Rods几何题,二分
来源:互联网 发布:淘宝订单体验 编辑:程序博客网 时间:2024/04/30 07:39
由于热胀冷缩,一根长度为L的木棒在温度上升n度的时候,会膨胀为L‘=(1+C*n)L,其中C为膨胀系数。
起初,一根木棒恰好卡在两块板子之间,现在加热令其膨胀,假定其膨胀为一个圆弧,为弧形的弓形高是多少?
每组输入给出的是原长,温度,膨胀系数
本质上就是,给你一条圆弧的拱形长度(跨度),求弓形高。
数学题,不过做起来并没有那么那么的显然,并不是直接推公式的
当然,设所求答案为x,得到以下两式
注意有两个未知量x和r,r为圆弧半径,要显式地表达x必须先显式地表达r,而方程2为超越方程
对此,我最初是走了两个二分,由于L和L'一开始就确定了,我对方程2二分出一个值作为r,之后再对方程1 二分得到x值,样例能对,但是wa
所以感觉两个二分对精度的损失过大了
于是改写了式子,过程中对每个x值用方程1求对应的r值,再利用方程2进行二分,这样实际上只有一个二分过程,精度得到提高
code:
#include<iostream>#include<cstdio>#include<cmath>#include<cstring>#include<string>#include<stack>#include<queue>#include<algorithm>#include<cstdlib>#define maxn 1001010#define inf 0x3f3f3f3f#define LL long longusing namespace std;const double pi=3.141592653589793;const double eps=1e-8;double L,t,c,L1,r;int main(){ while(scanf("%lf%lf%lf",&L,&t,&c)) { if(L<0&&t<0&&c<0)break; if(t==0.0) { printf("0.000\n"); continue; } L1=(1+t*c)*L; double low,high,mid; low=0; high=0.5*L; mid=(low+high)/2; while(high-low>eps) { mid=(low+high)/2; r=(4*mid*mid+L*L)/(8*mid); if(2*r*asin(L/(2*r))>=L1) high=mid; else low=mid; } printf("%.3lf\n",mid); }}
0 0
- POJ 1905 Expanding Rods几何题,二分
- POJ 1905 Expanding Rods (二分+计算几何)
- POJ 1905 Expanding Rods(几何+二分)
- POJ 1905-Expanding Rods(二分+计算几何)
- POJ - 1905-Expanding Rods-数论-二分&几何
- POJ 1905 Expanding Rods 几何加二分
- POJ-1905-Expanding Rods【二分】【计算几何】
- POJ 1905 Expanding Rods (二分+计算几何+精度处理)
- POJ 题目1905 Expanding Rods(二分,数学几何)
- POJ 1905 Expanding Rods(二分)
- poj--1905 Expanding Rods(二分)
- 【POJ 1905】 Expanding Rods (二分)
- POJ 1905 Expanding Rods二分
- poj 1905 Expanding Rods(二分)
- POJ Expanding Rods 1905 (二分)
- 【二分+几何】F - Expanding Rods
- Expanding Rods(二分+几何)
- poj1905 Expanding Rods(二分+几何)
- C++中的强制类型转换
- 经典算法总结与实现
- GDataXML 解析三方库
- Java对象循环引用,Java gc 如何回收
- shell脚本中生成的spool文件没有执行的语句
- POJ 1905 Expanding Rods几何题,二分
- nsq源码阅读笔记之nsqd(三)——diskQueue
- leetcode Path Sum
- Android中实现横屏竖屏的切换
- ubuntu linux下编辑更改镜像源
- USACO nocows
- python和php常用的时间处理
- JavaBean与JSON的转换
- Matlab的mapminmax函数说明