题面

传送门

分析



如图:已知AB=L,弧AB=L(1+nC)" role="presentation" style="position: relative;">AB=L,弧AB=L(1+nC)AB=L,弧AB=L(1+nC),M为AB中点,N为圆上一点,且ON垂直于AB于M,求MN

设半径为R" role="presentation" style="position: relative;">RR,∠AOM=θ" role="presentation" style="position: relative;">∠AOM=θ∠AOM=θ(弧度),MN=x" role="presentation" style="position: relative;">MN=xMN=x

则可列出方程组

{2Rθ=L(1+nc)(1)Rsin⁡θ=L2(2)x=R(1−cos⁡θ)(3)" role="presentation" style="position: relative;">⎧⎩⎨⎪⎪⎪⎪2Rθ=L(1+nc)(1)Rsinθ=L2(2)x=R(1−cosθ)(3){2Rθ=L(1+nc)(1)Rsin⁡θ=L2(2)x=R(1−cos⁡θ)(3)

若求出θ" role="presentation" style="position: relative;">θθ便可以求出x,所以我们从 θ" role="presentation" style="position: relative;">θθ入手,尝试解上面的方程组

由(1)(2)式得 θsin⁡θ=1+nC" role="presentation" style="position: relative;">θsinθ=1+nCθsin⁡θ=1+nC

本人数学不好,求不出上面的方程的解析解(如果有解析解可以在评论中指出)

于是采用二分的方法来近似求根

显然0&lt;θ≤π2" role="presentation" style="position: relative;">0<θ≤π20<θ≤π2

由图知θ" role="presentation" style="position: relative;">θθ越大,1+nC越大" role="presentation" style="position: relative;">1+nC越大1+nC越大

我们二分θ" role="presentation" style="position: relative;">θθ,设二分中点为mid,端点为[L,R]并计算midsin⁡mid" role="presentation" style="position: relative;">midsinmidmidsin⁡mid,若midsin⁡mid&gt;1+nC" role="presentation" style="position: relative;">midsinmid>1+nCmidsin⁡mid>1+nC,则寻找更小的,R=mid.否则寻找更大的,L=mid

还有几个细节:

1.π" role="presentation" style="position: relative;">ππ一定要很精确,否则会WA

2.设定的二分误差要尽量小

代码

#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#define eps 1e-11
#define pi 3.141592653589793
using namespace std;
double L,n,C,theta,x;
int main(){
while(scanf("%lf %lf %lf",&L,&n,&C)!=EOF){
if(L==n&&n==C&&C==-1) break;
if(n*C==0){
printf("0.000\n");
continue;
}
double l=eps,r=pi/2;//用弧度表示角
while(fabs(l-r)>eps){
double mid=(l+r)/2;
double hu=mid/sin(mid);
if(hu>1+n*C) r=mid;
else l=mid;
}
theta=l;
double R=L/(2*sin(theta));
printf("%.3f\n",R*(1-cos(theta)));
}
}

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. POJ 1840 Eqs 二分+map/hash

    Description Consider equations having the following form: a1x13+ a2x23+ a3x33+ a4x43+ a5x53=0 The co ...

  3. poj 2318 叉积+二分

    TOYS Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 13262   Accepted: 6412 Description ...

  4. poj 2049(二分+spfa判负环)

    poj 2049(二分+spfa判负环) 给你一堆字符串,若字符串x的后两个字符和y的前两个字符相连,那么x可向y连边.问字符串环的平均最小值是多少.1 ≤ n ≤ 100000,有多组数据. 首先根 ...

  5. POJ 1905 Expanding Rods 二分答案几何

    题目:http://poj.org/problem?id=1905 恶心死了,POJ的输出一会要lf,一会要f,而且精度1e-13才过,1e-12都不行,错了一万遍终于对了. #include < ...

  6. POJ - 1905 Expanding Rods(二分+计算几何)

    http://poj.org/problem?id=1905 题意 一根两端固定在两面墙上的杆,受热后变弯曲.求前后两个状态的杆的中点位置的距离 分析 很明显需要推推公式. 由②的限制条件来二分角度, ...

  7. 【二分答案】Expanding Rods POJ 1905

    题目链接:http://poj.org/problem?id=1905 题目大意:原长度为L的线段因受热膨胀为一段弧,线段L.弧长L'.温度n.膨胀率c满足L' =(1+n/c)*L;求线段的中点移动 ...

  8. poj 3061 题解(尺取法|二分

    题意 $ T $ 组数据,每组数据给一个长度 $ N $ 的序列,要求一段连续的子序列的和大于 $ S $,问子序列最小长度为多少. 输入样例 2 10 15 5 1 3 5 10 7 4 9 2 8 ...

  9. poj 1905 Expanding Rods (数学 计算方法 二分)

    题目链接 题意:将长度为L的棒子卡在墙壁之间.现在因为某种原因,木棒变长了,因为还在墙壁之间,所以弯成了一个弧度,现在求的是弧的最高处与木棒原先的地方的最大距离. 分析: 下面的分析是网上别人的分析: ...

随机推荐

  1. 前端每日实战:14# 视频演示如何用纯 CSS 创作一种侧立图书的特效

    效果预览 按下右侧的"点击预览"按钮在当前页面预览,点击链接全屏预览. https://codepen.io/zhang-ou/pen/deVgRM 可交互视频教程 此视频是可以交 ...

  2. Cookie 跨域???

    跨域的 “域” 指的是 URL,包括协议.域名.端口. cookie 和跨域没关系,只和域名有关,和端口无关. http://test1.demo.com:8080 与 http://test2.de ...

  3. RSA和AES工具类

    AESUtil import com.xxx.common.BssException; import com.xxx.common.constants.CommonConstants; import ...

  4. postman—Sandbox和断言

    Postman沙盒 Postman Sandbox是一个JavaScript执行环境,您可以在编写预请求脚本和测试脚本(在Postman和Newman中)时可用.在这个沙箱中执行您在预请求/测试脚本部 ...

  5. PHP生成静态网页的方法

    看到很多朋友在各个地方发帖问PHP生成静态文章系统的方法,以前曾做过这样一个系统,遂谈些看法,以供各位参考.兄弟先带大家回顾一些基本的概念. 一,PHP脚本与动态页面. PHP脚本是一种服务器端脚本程 ...

  6. [USACO08FEB]连线游戏Game of Lines

    题目背景 Farmer John最近发明了一个游戏,来考验自命不凡的贝茜. 题目描述 Farmer John has challenged Bessie to the following game: ...

  7. Ubuntu 16.04下使用docker部署Redis主从复制

    (以下docker相关的命令,需要在root用户环境下或通过sudo提升权限来进行操作.) 1.拉取Redis镜像到本地 docker pull redis 2. 准备Redis主从配置文件 Redi ...

  8. 安装memcached和elasticsearch服务并systemctl管理

    [root@izbp18dv3a3metugyd02qxz bin]# rpm -qa | grep memcache [root@izbp18dv3a3metugyd02qxz bin]# yum ...

  9. 170817关于Listener的知识点

    1.  Listener   监听器简介                    Listener是JavaWeb中三大组件之一.Servlet.Filter.Listener              ...

  10. Matlab中imfilter()函数的用法

    Matlab中imfilter()函数的用法 功能:对任意类型数组或多维图像进行滤波.用法:B = imfilter(A,H) B = imfilter(A,H,option1,option2,... ...