POJ1905-Expanding Rods-二分答案
一根细棒升温时会变长,在两面墙中间,会变成一个弓形。
给出变长后的长度,求新的细棒中心与没伸长时的中心的距离。
简单的数学推导后就可以二分答案了,一开始没完全掌握二分的姿势,wa了好多。而且poj double输出要用%f,用%lf就wa了。
#include <cstdio>
#include <cmath>
#include <algorithm> using namespace std; const double eps = 1e-;
double n,c,L; double func(double x)
{
//if(fabs(x-0) < eps) return ;
double r = (x*x+L*L/4.0)/(*x);
return *r*asin(L/(2.0*r));
} int main()
{
while(scanf("%lf%lf%lf",&L,&n,&c))
{
if(L< && n< && c<)
break; double low = 0.0,high = 0.5*L;
double mid = (low+high)/2.0;
double s = (+n*c)*L;
double ans = ; while(high-low>eps)
{
//printf("%lf %lf %lf\n",low,mid,high);
//printf("%lf %lf %lf\n",func(low),func(mid),func(high)); if(func(mid) < s)
low = mid;
else
high = mid; mid = (low+high)/2.0;
}
//printf("%f %f\n",mid,L);
printf("%.3f\n",mid);
}
}
POJ1905-Expanding Rods-二分答案的更多相关文章
- POJ 1905 Expanding Rods 二分答案几何
题目:http://poj.org/problem?id=1905 恶心死了,POJ的输出一会要lf,一会要f,而且精度1e-13才过,1e-12都不行,错了一万遍终于对了. #include < ...
- Expanding Rods(二分POJ1905)
Expanding Rods Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 13688 Accepted: 3527 D ...
- poj1905 Expanding Rods(二分)
题目链接:https://vjudge.net/problem/POJ-1905 题意:有一根长len的木棍,加热了n度,长度会膨胀为len*(1+n*c),c为膨胀系数.现在把这根木棍夹在两堵墙之间 ...
- 二分法 (UVA10668 Expanding Rods)(二分+几何)
转载请注明出处:優YoU http://user.qzone.qq.com/289065406/blog/1301845324 大致题意: 一根两端固定在两面墙上的杆 受热弯曲后变弯曲.求前后两个状态 ...
- Expanding Rods(二分)
Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 10287 Accepted: 2615 Description When ...
- poj 1905 Expanding Rods 二分
/** 题解晚上写 **/ #include <iostream> #include <math.h> #include <algorithm> #include ...
- 【二分答案】Expanding Rods POJ 1905
题目链接:http://poj.org/problem?id=1905 题目大意:原长度为L的线段因受热膨胀为一段弧,线段L.弧长L'.温度n.膨胀率c满足L' =(1+n/c)*L;求线段的中点移动 ...
- UVA 10668 - Expanding Rods(数学+二分)
UVA 10668 - Expanding Rods 题目链接 题意:给定一个铁棒,如图中加热会变成一段圆弧,长度为L′=(1+nc)l,问这时和原来位置的高度之差 思路:画一下图能够非常easy推出 ...
- D - Expanding Rods POJ - 1905(二分)
D - Expanding Rods POJ - 1905 When a thin rod of length L is heated n degrees, it expands to a new l ...
- POJ 1905:Expanding Rods 求函数的二分
Expanding Rods Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 13780 Accepted: 3563 D ...
随机推荐
- 解密:Python风靡全宇宙,首要原因竟是它?
就让我们从近年来大数据的兴起说起,为你娓娓道来Python火爆的真正原因. 郁闷的大数据程序员 随着大数据的崛起,大多数行业发现自己进入了一种恐慌状态:他们花费了大量的时间和金钱来建立他们的大数据渠道 ...
- hibernate 解决 java.lang.NoClassDefFoundError: Could not initialize class org.hibernate.validator.internal.engine.xxx 这类的问题
<!-- 解决 java.lang.NoClassDefFoundError: Could not initialize class org.hibernate.validator.intern ...
- vue-cli 3.0 axios 跨域请求代理配置及生产环境 baseUrl 配置
1. 开发环境跨域配置 在 vue.config.js 文件中: module.exports = { runtimeCompiler: true, publicPath: '/', // 设置打包文 ...
- Flutter - 创建自适应的Android app 图标
上一篇文章说到 Flutter - 自动生成Android & iOS图标 通过flutter_launcher_icons 可以一键生成所有的Icon 到此基本什么问题也没有,如果你用io ...
- WPF制作带明细的环形图表
效果 明细用Popup实现的,录gif时,Popup显示不出来,不知道为什么,所以静态图凑合看吧 大体思路 图表使用Arc+Popup实现 图表分为两部分,一是环形部分,一是标注的明细部分. 环形部分 ...
- CrackMe-005全破详解(图文+源码)--上篇
逆向破解 | 逆向 | 逆向分析 | CrackMe | Crack | CrackMe5 | CrackMe05 前言 CrackMe005,都说比较变态,很多人给放过去了,但是我还是决定上了它,既 ...
- Minimum Integer CodeForces - 1101A (思维+公式)
You are given qq queries in the following form: Given three integers lili, riri and didi, find minim ...
- Maximal Binary Matrix CodeForces - 803A (贪心+实现)
题目链接 题意有点坑: 给你一个N*N的矩阵,让你填入K个1,使之整个矩阵关于左上到右下的对角线对称,并且这个要求这个矩阵的字典序最大. 对矩阵的字典序的定义是从每一行的第一个元素开始比较,大着为字典 ...
- java面对对象(六)--内部类、匿名内部类
内部类 可以在一个类的内部定义另一个类这种类成为内部类或嵌套类,比如: class Outer{ … class Inner{ …. } } class Outer1{} // 这个Inner1不是O ...
- 使用Java+Kotlin双语言的LeetCode刷题之路(一)
LeetCode learning records based on Java,Kotlin,Python...Github 地址 序号对应 LeetCode 中题目序号 1 两数之和 给定一个整数数 ...