2020牛客寒假算法基础集训营6 J签到题

地址

题目描述

现有一个边长为正整数的三角形,问能否以其三个顶点为圆心画三个圆,使三个圆两两外切

三边长均不超过 10^8。

输入描述

三个正整数,表示三角形的边长

输出描述

如果三条边不能构成三角形,输出“wtnl”

如果三条边能构成三角形但不能画出符合要求的圆,输出“No”

否则输出一行“Yes”

然后在第二行输出一组方案,按升序给出三个圆的半径,保留两位小数

示例1

输入

2 3 3

输出

Yes
1.00 1.00 2.00

思路

很简单,我WA了好多次,也想了半天,主要就是我的几何太烂了,还有就是输出“wtnl”,而我写成了“wtn1”。

这道题其实没有NO的情况。

我们设三个圆的半径为x,y,z,三角形的三边为a,b,c。

可知x+y=a,x+z=b,y+z=c。

求解可得

x=(a+b-c)/2,y=(a+c-b)/2,z=(b+c-a)/2

代码

#include <iostream>
#include <cstring>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <queue>
#include <cmath>
#include <cctype>
#include <stack>
#include <map>
#include <cstring>
#include <sstream>
#include <set>
#include <list>
#include <fstream>
#include <iomanip>
#include <assert.h>

#define ll long long
#define ull unsigned long long
#define pii std::pair<int, int>
#define op                            \
    std::ios::sync_with_stdio(false); \
    std::cin.tie(0);

const int INF = 0x3f3f3f3f;
const int maxn = (10000 + 5);
const int mod = (998244353);

int a,b,c;
double ans[5];
int main()
{
    scanf("%d %d %d",&a,&b,&c);
    if((a+b>c)&&(a+c>b)&&(b+c>a))
    {
        ans[0]=(a+b-c)*1.0/2.0;
        ans[1]=(a+c-b)*1.0/2.0;
        ans[2]=(b+c-a)*1.0/2.0;
        std::sort(ans,ans+3);
        printf("Yes\n");
        printf("%.2lf %.2lf %.2lf\n",ans[0],ans[1],ans[2]);
    }
    else
        printf("wtnl\n");
    return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值