POJ 1905 Expanding Rods 几何加二分
2015-09-24 14:14
609 查看
Expanding Rods
![]() When a thin rod of length L is heated n degrees, it expands to a new length L'=(1+n*C)*L, where C is the coefficient of heat expansion. When a thin rod is mounted on two solid walls and then heated, it expands and takes the shape of a circular segment, the original rod being the chord of the segment. Your task is to compute the distance by which the center of the rod is displaced. Input The input contains multiple lines. Each line of input contains three non-negative numbers: the initial lenth of the rod in millimeters, the temperature change in degrees and the coefficient of heat expansion of the material. Input data guarantee that no rod expands by more than one half of its original length. The last line of input contains three negative numbers and it should not be processed. Output For each line of input, output one line with the displacement of the center of the rod in millimeters with 3 digits of precision. Sample Input 1000 100 0.0001 15000 10 0.00006 10 0 0.001 -1 -1 -1 Sample Output 61.329 225.020 0.000 Source Waterloo local 2004.06.12 |
[Discuss]
求圆弧的高 网上找的公式 R=(4*H*H+L*L)/(8*H) S=2*R*arcsin(L/(2*R))
给出上界L*1/2下届0 二分枚举求满足式子的H
G++WA好几发 C++秒过 Orz
ACcode:
#include <map>
#include <queue>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stdlib.h>
#include <iostream>
#include <algorithm>
#define rd(x) scanf("%d",&x)
#define rd2(x,y) scanf("%d%d",&x,&y)
#define ll long long int
#define maxn 100005
#define mod 1000000007
#define INF 0x3f3f3f3f //int×î´óÖµ
#define FOR(i,f_start,f_end) for(int i=f_start;i<=f_end;++i)
#define MT(x,i) memset(x,i,sizeof(x))
#define PI acos(-1.0)
#define E exp(1)
#define esp 1e-5
using namespace std;
int main(){
double l,n,c,r,s;
while(cin>>l>>n>>c){
if(l<0&&n<0&&c<0)break;
s=(1+n*c)*l;
double up=l*0.5;
double down=0;
double now;
while(up-down>esp){
now=(up+down)/2;
r=(4*now*now+l*l)/(8*now);
if(2*r*asin(l/(2*r))<s)
down=now;
else
up=now;
}
printf("%.3lf\n",now);
}
return 0;
}
/**
1000 100 0.0001 15000 10 0.00006 10 0 0.001 -1 -1 -1**/
相关文章推荐
- stm32 IAP + APP ==>双剑合一
- AWS RDS 无super权限下创建function
- qt中如果用qDebug输出彩色调试信息
- Objective-C: 字符串NSString与NSMutableString
- Linux Hackers/Suspicious Account Detection
- android EditText与TextView几个常用的属性
- The sum - SGU 122(斐波那契前N项和)
- Android中事件传递机制的总结
- URAL 1982 Electrification Plan
- JavaScript面向对象(3)
- 关于android 使用bitmap的OOM心得和解决方案
- 链表的那些事儿<一>
- Bitmap保存到本地
- 为什么百度地图不显示
- BrokenKeyBoard
- POJ 3468 A Simple Problem with Integers
- javascript预加载图片的处理(src无法加载图片)
- 链表的那些事儿<一>
- 设计模式 9 —— 模板方法模式
- 欢迎使用CSDN-markdown编辑器