zoukankan      html  css  js  c++  java
  • 三角形(惯性思维)



    Problem Description
    给定三条边,请你判断一下能不能组成一个三角形。
     
    Input
    输入数据第一行包含一个数M,接下有M行,每行一个实例,包含三个正数A,B,C。其中A,B,C <1000;
     
    Output
    对于每个测试实例,如果三条边长A,B,C能组成三角形的话,输出YES,否则NO。
     
    Sample Input
    2 1 2 3 2 2 2
     
    Sample Output
    NO
    YES
                   一看这道题目,这么简单,结果wa了好几次。。。惯性思维了,没考虑到边长不只是整型。
     1 #include<iostream>
     2 #include<iomanip>
     3 //#include<bits/stdc++.h>
     4 #include<cstdio>
     5 #include<algorithm>
     6 #include<cmath>
     7 #define PI  3.14159265358979
     8 #define LL long long
     9 #define INF  10000001000
    10 #define  eps   0.00000001
    11 using namespace std;
    12 int main()
    13 {
    14     LL T;
    15    double a,b,c;
    16     cin>>T;
    17     while(T--)
    18     {
    19         cin>>a>>b>>c;
    20         if(a+b>c&&a+c>b&&b+c>a) puts("YES");
    21         else puts("NO");
    22 
    23     }
    24 }
    View Code
  • 相关阅读:
    跳跃游戏
    不同路径
    最大子序和
    最长回文子序列
    最长公共子序列
    零钱兑换
    合并区间
    寻找数组的中心索引
    制造小程序中的一些经验
    h5写的一个签到积分系统
  • 原文地址:https://www.cnblogs.com/Auroras/p/10802477.html
Copyright © 2011-2022 走看看