zoj 3806 Incircle and Circumcircle

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 AB, C is denoted ΔABC. And its three sides, BCCAAB are often denoted ab 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 ab and c. Now you are given r and R, can you calculate a valid triple (abc)?

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 ab 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 ab 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!


题意:

题意很简单,就知道一个三角形的内切圆与外接圆的半径,让你求出三角形的三条边。

分析:

这是浙大月赛的题,在比赛的过程中没做出来。颇感遗憾。首先知道三角形的两个半径,那么,我们可以猜测这个三角形可能为特殊三角形,比如正三角形、直角三角形、等腰三角形等等。经过分析本题的答案不唯一,那么两个圆都会存在一个等腰三角形,这个也可以证明。那么我们求得三角形就为一个等腰三角形。之前我得出了当这个三角形为正三角形的时候就是边界条件,这时的内切圆会最大。然后二分三角形的底,得出答案。

代码:参考:http://blog.csdn.net/u014733623/article/details/38800873


#include<algorithm>
#include<iostream>
#include<fstream>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;

#ifdef __int64
typedef __int64 LL;
#else
typedef long long LL;
#endif

#define inf 0x7ffffffff
#define eps 1e-10

#define N 1000005

int main() {
    double R,r;
    while(~scanf("%lf %lf",&r,&R)) {

        if(r*2>R) {
            cout<<"NO Solution!"<<endl;
            continue;
        }
        double l=0,rr=R*sqrt(3)/2;
        double mid;
        double O,o,h,bian;

        while(rr-l>eps) {
            mid=(rr+l)/2;
            O=sqrt(R*R-mid*mid);
            h=O+R;
            bian=sqrt(h*h+mid*mid);
            o=(2*mid*h)/(2*bian+mid*2);
            if(o<r)
                l=mid;
            else
                rr=mid;

        }
        mid=(rr+l)/2;
        O=sqrt(R*R-mid*mid);
        h=O+R;
        bian=sqrt(h*h+mid*mid);
        printf("%.18f %.18f %.18f\n",mid*2,bian,bian);
    }
    return 0;
}





  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值