题目链接:http://poj.org/problem?id=1905

题目大意:原长度为L的线段因受热膨胀为一段弧,线段L、弧长L‘、温度n、膨胀率c满足L' =(1+n/c)*L;求线段的中点移动的最小距离。

’?‘代表的线段就是要求的距离。

怎么办呢?用分治,二分答案,验证弧长是否为目标弧长再进行调整。

首先利用相交弦定理[BA×EA=CA×DA]算出other(AE)

然后用(mid+other)/2得到r(CO)

再用r-mid(AO)除以r(CO)算出cos(θ)

再用acos算出θ,然后算出弧长

贴代码:

#include<cstdio>
#include<cmath>
using namespace std;
double L,n,c,_L;
int main()
{
while(scanf("%lf%lf%lf",&L,&n,&c),L>=0)
{ _L=(1+n*c)*L;
if(L==0||n==0||c==0){puts("0.000");continue;}//特判,不然后面会除以0
double l=0,r=L/2;
while(l<r-(1e-6))//注意精度,太大会WA,太小会TLE
{
double mid=(l+r)/2,other=L*L/(mid*4);
double R=(mid+other)/2,cos_sita,sita;
cos_sita=(R-mid)/R;sita=acos(cos_sita);
double hc=R*sita*2;
if(hc>_L) r=mid;
else l=mid;
}
printf("%.3lf\n",l);
}
}

【二分答案】Expanding Rods POJ 1905的更多相关文章

  1. 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 ...

  2. Expanding Rods POJ 1905 二分

    Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 17050   Accepted: 4503 Description When ...

  3. POJ 1905:Expanding Rods 求函数的二分

    Expanding Rods Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 13780   Accepted: 3563 D ...

  4. POJ 1905 Expanding Rods(二分)

    Expanding Rods Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 20224 Accepted: 5412 Descr ...

  5. poj 1905 Expanding Rods(木杆的膨胀)【数学计算+二分枚举】

                                                                                                         ...

  6. POJ 1905 Expanding Rods

                           Expanding Rods Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 1 ...

  7. UVA 10668 - Expanding Rods(数学+二分)

    UVA 10668 - Expanding Rods 题目链接 题意:给定一个铁棒,如图中加热会变成一段圆弧,长度为L′=(1+nc)l,问这时和原来位置的高度之差 思路:画一下图能够非常easy推出 ...

  8. 字符串hash + 二分答案 - 求最长公共子串 --- poj 2774

    Long Long Message Problem's Link:http://poj.org/problem?id=2774 Mean: 求两个字符串的最长公共子串的长度. analyse: 前面在 ...

  9. POJ 3104 Drying(二分答案)

    题目链接:http://poj.org/problem?id=3104                                                                  ...

随机推荐

  1. Python学习日记(一) String函数使用

    s = "abcaDa a" s2 = "123a abc ABCSAa s " s3 = "\tas \t\tb123" s4 = ' & ...

  2. python基础 — Queue 队列

    queue介绍 queue是python中的标准库,俗称队列. 在python中,多个线程之间的数据是共享的,多个线程进行数据交换的时候,不能够保证数据的安全性和一致性,所以当多个线程需要进行数据交换 ...

  3. canal+kafka订阅Mysql binlog将数据异构到elasticsearch(或其他存储方式)

    canal本质就是"冒充"从库,通过订阅mysql bin-log来获取数据库的更改信息. mysql配置(my.cnf) mysql需要配置my.cnf开启bin-log日志并且 ...

  4. kotlin --- 时间戳与字符串互相转换

    直接贴代码,清晰易懂.喜欢点个赞 class Timestamp { /** * Timestamp to String * @param Timestamp * @return String */ ...

  5. Pycharm安装文档教程

    1 找到安装包 双击 2 3 可以更改安装路径 4 5 6 7 等待安装完成 8 作者:含笑半步颠√ 博客链接:https://www.cnblogs.com/lixy-88428977 声明:本文为 ...

  6. vscode 连接远程服务器 sftp

    1.在vscode 应用商店搜索 sftp 下载安装 2.ctrl+shift+p 搜索sftp:config 生成sftp.json 3.配置你的服务器信息{ "name": & ...

  7. Spring Spring boot 获取IOC中的bean,ApplicationContext

    https://blog.csdn.net/weixin_38361347/article/details/89304414 https://www.jianshu.com/p/9ea13b00b1d ...

  8. 让table中的td不会被过长的文字撑开,并且自动出现省略号

    <style type="text/css"> table {width:600px;table-layout:fixed;} td {white-space:nowr ...

  9. kubernetes第二章--集群搭建

  10. springboot整合ActiveMQ1(基本使用)

    基本使用,https://www.tapme.top/blog/detail/2018-09-05-10-38 主备模式,https://www.tapme.top/blog/detail/2018- ...