zoukankan      html  css  js  c++  java
  • hdu2039java

    三角形

    Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
    Total Submission(s): 69908    Accepted Submission(s): 23479


    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

    /*import java.util.*;
    class Main{
    public static void main(String args[])
    {Scanner cin=new Scanner(System.in);
    int n=cin.nextInt();
    while(n-->0)
    {double []a=new double[3];
    double t;
    for(int i=0;i<3;i++)
    a[i]=cin.nextDouble();
    for(int i=0;i<2;i++)
    {for(int j=i+1;j<3;j++)
    {if(a[i]>a[j])
    {t=a[i];
    a[i]=a[j];
    a[j]=t;
    }
    }
    }
    if(a[0]+a[1]>a[2]&&a[2]-a[0]<a[1])
    System.out.println("YES");
    else
    System.out.println("NO");
    }
    }
    }*/
    import java.util.*;
    class Main{
    public static void main(String args[])
    {Scanner cin=new Scanner(System.in);
    int n=cin.nextInt();
    while(n-->0)
    {double a,b,c;
    a=cin.nextDouble();
    b=cin.nextDouble();
    c=cin.nextDouble();
    if(a+b>c&&b+c>a&&a+c>b)
    System.out.println("YES");
    else
    System.out.println("NO");
    }
    }
    }

    以上两个都可以,但第二个代码和复杂度都要比第一个的小;特别注意输入要用双精度的数值;

     
  • 相关阅读:
    BZOJ 1630/2023 Ant Counting 数蚂蚁
    BZOJ 3997 组合数学
    BZOJ 2200 道路与航线
    BZOJ 3181 BROJ
    BZOJ 4011 落忆枫音
    BZOJ 4027 兔子与樱花
    vijos 1741 观光公交
    vijos 1776 关押罪犯
    vijos 1780 开车旅行
    5、异步通知机制
  • 原文地址:https://www.cnblogs.com/1314wamm/p/5312617.html
Copyright © 2011-2022 走看看