Expanding Rods POJ 1905 二分
Time Limit: 1000MS | Memory Limit: 30000K | |
Total Submissions: 17050 | Accepted: 4503 |
Description

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
Output
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
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<sstream>
#include<algorithm>
#include<queue>
#include<deque>
#include<iomanip>
#include<vector>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<fstream>
#include<memory>
#include<list>
#include<string>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MAXN 20009
#define N 21
#define MOD 1000000
#define INF 1000000009
const double eps = 1e-;
const double PI = acos(-1.0);
/*
给一个弦长和弧长 求圆心到弦的距离 直接求不太好求
可以用二分搜索
为了避免精度损失应该 尽量少用除法! 一开始想枚举弧度有点跑偏。。
因为枚举弧度 :sgn(L*x - 2 * l*sin(x / 2)) == 0 这个表达式判断失败后不好分析下一步二分的范围
还是直接枚举H h越小 弧长越大
*/
double L, c, n, l;
inline int sgn(double x)
{
//cout << x << endl;
if (fabs(x - ) < eps)
return ;
else if (x > )
return ;
else
return -;
}
int main()
{
while (scanf("%lf%lf%lf", &L, &c, &n), !(L<&&c<&&n<))
{
l = ( + n*c)*L;
double beg = , end = L/;
while (sgn(end - beg) > )
{
double mid = (beg + end) / ;
double r = ( * mid*mid + L*L) / / mid;
//cout << ":" << mid << endl;
if (sgn(*r*asin(L//r)-l) < )//弧长应当加大,所以h应该减小
{
beg = mid;
}
else
end = mid;
}
printf("%.3lf\n", beg);
}
}
Expanding Rods POJ 1905 二分的更多相关文章
- 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 ...
- 【二分答案】Expanding Rods POJ 1905
题目链接:http://poj.org/problem?id=1905 题目大意:原长度为L的线段因受热膨胀为一段弧,线段L.弧长L'.温度n.膨胀率c满足L' =(1+n/c)*L;求线段的中点移动 ...
- poj 1905 Expanding Rods (数学 计算方法 二分)
题目链接 题意:将长度为L的棒子卡在墙壁之间.现在因为某种原因,木棒变长了,因为还在墙壁之间,所以弯成了一个弧度,现在求的是弧的最高处与木棒原先的地方的最大距离. 分析: 下面的分析是网上别人的分析: ...
- POJ 1905:Expanding Rods 求函数的二分
Expanding Rods Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 13780 Accepted: 3563 D ...
- POJ 1905 Expanding Rods(二分)
Expanding Rods Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 20224 Accepted: 5412 Descr ...
- poj 1905 Expanding Rods(木杆的膨胀)【数学计算+二分枚举】
...
- POJ 1905 Expanding Rods
Expanding Rods Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 1 ...
- UVA 10668 - Expanding Rods(数学+二分)
UVA 10668 - Expanding Rods 题目链接 题意:给定一个铁棒,如图中加热会变成一段圆弧,长度为L′=(1+nc)l,问这时和原来位置的高度之差 思路:画一下图能够非常easy推出 ...
- Expanding Rods(二分POJ1905)
Expanding Rods Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 13688 Accepted: 3527 D ...
随机推荐
- 解决UTF-8方法归纳
1:通过spring配置过滤器解决 <!-- 配置Spring提供的字符编码过滤器 --> <filter> <filter-name>SpringCharacte ...
- C# 清除coockies
if (Request.Cookies["zxcookies"] != null) { HttpCookie mycookie; ...
- NetCore Netty 框架 BT.Netty.RPC 系列随讲 二 WHO AM I 之 NETTY/NETTY 与 网络通讯 IO 模型之关系?
一:NETTY 是什么? Netty 是什么? 这个问题其实百度上一搜一堆. 这是官方话的描述:Netty 是一个基于NIO的客户.服务器端编程框架,使用Netty 可以确保你快速和简单的开发出一个 ...
- 【LeetCode】-- 73. Set Matrix Zeroes
问题描述:将二维数组中值为0的元素,所在行或者列全set为0:https://leetcode.com/problems/set-matrix-zeroes/ 问题分析:题中要求用 constant ...
- 设置靠近 水平居中的主体内容Div 的 左侧位置固定的Div
示例效果: 1.主体内容的divMain 水平居中: 2.divLeft 靠近divMain ,位置固定,不随垂直滚动条而动: 相关代码: <html> <head runat=&q ...
- Sublime Text2安装emmet
一.安装Package Control 如果Preferences中没有Package Control,需要手动安装.安装方法如下: 访问Package Controls站点复制一段python命令安 ...
- 实现strcpy
#include <stddef.h> char* strcpy(char* dest, const char* src) { if (dest == NULL || src == NUL ...
- C#——枚举格式转换与比较
定义一个枚举类型: public enum City { 北京, 上海, 广州 } 控制台判断: static void Main(string[] args) { Console.WriteLine ...
- dubbo之配置规则
配置规则 向注册中心写入动态配置覆盖规则 1.该功能通常由监控中心或治理中心的页面完成. RegistryFactory registryFactory = ExtensionLoader.getEx ...
- Caffe2:添加CUDA路径
在使用Eclipse时候,仍然出现 libcuda.so 找不到的情况..... 原因:cuda环境没有设置到系统环境中. 方案: 设置CUDA path: 在bashrc中添加路径,只对当前用户产生 ...