Incircle and Circumcircle


Time Limit: 2 Seconds Memory Limit: 65536 KB Special Judge

A triangle is one the basic shapes in geometry. It's a polygon with three vertices and three sides which are line segments. A triangle with vertices A, B, C is denoted ΔABC. And its three sides, BC, CA, AB are often denoted a, b and c.

The incircle of a triangle is the largest circle contained in the triangle, it is tangent to the three sides. The center of the incircle is called the triangle's incenter and the radius of the incircle is called inradius, which is denoted r.

The circumcircle of a triangle is the circle which passes through all its three vertices. The center of the this circle is called circumcenter and its radius is called circumradius, which is denoted R.

It's very easy to calculate r and R after knowing a, b and c. Now you are given r and R, can you calculate a valid triple (a, b, c)?

Input

There are multiple cases. Each case has two positive integers r and R in one line. (r and R are less than 105)

Ouput

For each case, print three floating numbers a, b and c in one line if it's possible to get r and R. If there are no possible tuples, print "NO Solution!".

The judge program uses your a, b and c to calculate the inradius and circumradius. Only the relative error of your inradius and circumradius less than 10-8 will be accepted.

Sample Input

1 2
2 5
9 9

Sample Ouput

3.464101615137754587 3.464101615137754587 3.464101615137754587
6 8 10
NO Solution!

题目大意:给你一个三角形的内切圆半径跟外接圆半径,求解出符合条件的三角形,输出三角形的三条边的长度,如果没有符合条件的三角形,输出“NO Solution!”。

解题思路:这个题是SP,既是因为情况不唯一,而且还有精度的误差。

首先能够想到的就是NO Solution!的情况,即当内切圆半径等于1/2外接圆半径时,此时内切圆最大,而三角形为等边三角形,如图。

其次要解决的就是怎么构造三角形的问题,因为解不唯一,所以只要列举出一种解就OK,于是就很容易的想到构造等腰三角形,在最大与最小之间二分等腰三角形的底边长度,解三角形得到答案,如图。

思路就是二分,不明白的看下面的图;

ps:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=5338

浙大月赛ZOJ Monthly, August 2014其他题

http://www.cnblogs.com/yuyixingkong/p/3935199.html

#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
int main()
{
double r,R;
double ldi,rdi,mi;//左,右,中
double H,h,yao,o;//H:外心到等腰三角形底边的距离;h:等腰三角形的高;yao:表示腰长;o:内心半径
double eps=1e-;
while(~scanf("%lf%lf",&r,&R))
{
if(R>*r)
{
printf("NO Solution!\n");
continue;
}
ldi=;
rdi=R*sqrt()/;//最大等边三角形;所以区间长度最长是
while(rdi-ldi>eps)
{
mi=(rdi+ldi)/;
H=sqrt(R*R-mi*mi);
h=H+R;
yao=sqrt(h*h+mi*mi);
o=(mi*h)/(yao+mi);//等腰三角形同面积法
if(o<r)
ldi=mi;
else
rdi=mi;
}
mi=(rdi+ldi)/;
H=sqrt(R*R-mi*mi);
h=H+R;
yao=sqrt(h*h+mi*mi);
o=(mi*h)/(yao+mi);
printf("%.18f %.18f %.18f\n",mi*,yao,yao);
}
return ;
}

Incircle and Circumcircle(二分+几何)浙大月赛zoj3806(详解版)图的更多相关文章

  1. 几何:pick定理详解

    一.概念 假设P的内部有I(P)个格点,边界上有B(P)个格点,则P的面积A(P)为:A(P)=I(P)+B(P)/2-1. 二.说明 Pick定理主要是计算格点多边形(定点全是格点的不自交图形)P的 ...

  2. 浙大月赛ZOJ Monthly, August 2014

    Abs Problem Time Limit: 2 Seconds Memory Limit: 65536 KB Special Judge Alice and Bob is playing a ga ...

  3. 浙大&川大提出脉冲版ResNet:继承ResNet优势,实现当前最佳

    浙大&川大提出脉冲版ResNet:继承ResNet优势,实现当前最佳 选自arXiv,作者:Yangfan Hu等,机器之心编译. 脉冲神经网络(SNN)具有生物学上的合理性,并且其计算潜能和 ...

  4. AtCoder Regular Contest 069 F Flags 二分,2-sat,线段树优化建图

    AtCoder Regular Contest 069 F Flags 二分,2-sat,线段树优化建图 链接 AtCoder 大意 在数轴上放上n个点,点i可能的位置有\(x_i\)或者\(y_i\ ...

  5. 二分算法题目训练(三)——Anton and Making Potions详解

    codeforces734C——Anton and Making Potions详解 Anton and Making Potions 题目描述(google翻译) 安东正在玩一个非常有趣的电脑游戏, ...

  6. 二分算法题目训练(二)——Exams详解

    CodeForces732D——Exams 详解 Exam 题目描述(google翻译) Vasiliy的考试期限将持续n天.他必须通过m门科目的考试.受试者编号为1至m. 大约每天我们都知道当天可以 ...

  7. 二分算法题目训练(一)——Shell Pyramid详解

    HDU2446——Shell Pyramid 详解 Shell Pyramid 题目描述(Google 翻译的) 在17世纪,由于雷鸣般的喧嚣,浓烟和炽热的火焰,海上的战斗与现代战争一样.但那时,大炮 ...

  8. 记次浙大月赛 134 - ZOJ Monthly, June 2014

    链接 虽做出的很少,也记录下来,留着以后来补..浙大题目质量还是很高的 B 并查集的一些操作,同类和不同类我是根据到根节点距离的奇偶判断的,删点是直接新加一个点,记得福大月赛也做过类似的,并差集的这类 ...

  9. hdu 4033 二分几何

    参考:http://blog.csdn.net/libin56842/article/details/26618129 题意:给一个正多边形内点到其他顶点的距离(逆时针给出),求正多边形的边长 二分多 ...

随机推荐

  1. 微服务统一登陆认证怎么做?JWT ?

    无状态登录原理 1.1.什么是有状态? 有状态服务,即服务端需要记录每次会话的客户端信息,从而识别客户端身份,根据用户身份进行请求的处理,典型的设计如tomcat中的session. 例如登录:用户登 ...

  2. 「PKUSC2018」主斗地(暴搜)

    这道斗地主比 \(PKUWC\) 那道可做多了... 我们用 \(NOIP\) 那道斗地主的思路:暴搜出三代和四代,贪心出散牌. 还有jry为什么要出xx网友而不出他的另一个老婆 我们发现两个人的每回 ...

  3. 游戏AI玩伴,是“神队友”还是“猪队友”?

    “一代英豪”暴雪迎来了自己的暴风雪. 2月13日,动视暴雪公布了2018年全年财报.财报显示,暴雪第四季度营业收入仅为28.4亿美元,低于华尔街分析师预期的30.4亿美元.在公布了财报业绩后,该公司又 ...

  4. 跟着刚哥学习Spring框架--AOP(五)

    AOP AOP(Aspect Oriented Programming),即面向切面编程,可以说是OOP(Object Oriented Programming,面向对象编程)的补充和完善.OOP引入 ...

  5. js获取n分钟(或n小时或n个月)后(或前)的时间(日期)

    标题有点绕,其实意思就是根据系统当前时间,获取n分钟或n小时或n个月后的时间. 例如:当前时间下,获取10分钟后的时间. var date=new Date(); //1. js获取当前时间 var ...

  6. Java入门开发POI读取导入Excel文件

    Apache POI是Apache开发的开源的跨平台的 Java API,提供API给Java程序对Microsoft Office格式档案进行各种操作. POI中Excel操作很简单,主要类有 HS ...

  7. shopify网站转化率优化之结账页checkout优化

    昨天分享了“利用GOOGLE地图API实现shopify结账页checkout地址自动填写地址字段”是个非常屌的功能,但shopify默认的结账页checkout是这样的如图 [caption id= ...

  8. 【2019北京集训2】duck 线段树优化建图+tarjan

    题目大意:给你$n$个点,第$i$个点有点权$v_i$.你需要将这$n$个点排成一排,第$i$个点的点权能被累加当且仅当这个点前面存在编号在$[l_i,r_i]$中的点,问你这些点应该如何排列,点权和 ...

  9. (转)使用 db2pd 命令进行监视和故障诊断

    原文:https://www.ibm.com/support/knowledgecenter/zh/SSEPGG_9.7.0/com.ibm.db2.luw.admin.trb.doc/doc/c00 ...

  10. Metasploit数据库问题汇总

    数据库在metaspoit中是相当重要的,当做一个大型渗透测试项目的时候,收集到的信息是相当大的,当和你的同伴一起协同作战的时候,你们可能 在不同的地方,所以数据共享很重要了!而且Metasploit ...