zoukankan      html  css  js  c++  java
  • HDU 5655 四边形判断

    CA Loves Stick

    Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)
    Total Submission(s): 563    Accepted Submission(s): 202


    Problem Description
    CA loves to play with sticks.
    One day he receives four pieces of sticks, he wants to know these sticks can spell a quadrilateral.
    (What is quadrilateral? Click here: https://en.wikipedia.org/wiki/Quadrilateral)
     
    Input
    First line contains T denoting the number of testcases.
    T testcases follow. Each testcase contains four integers a,b,c,d in a line, denoting the length of sticks.
    1T1000, 0a,b,c,d2631
     
    Output
    For each testcase, if these sticks can spell a quadrilateral, output "Yes"; otherwise, output "No" (without the quotation marks).
     
    Sample Input
    2 1 1 1 1 1 1 9 2
     
    Sample Output
    Yes No
     
    Source
     
    题意: 输入四边长 a,b,c,d判断能否组成四边形
    题解: 1.根据边长的范围要考虑0
              2.四边形判断条件:升序排列后 最大边小于另外三边之和
              3.根据边长的范围:a[0]>a[3]-a[2]-a[1] (加法处理会爆数据范围 应当移项 减法处理)
     
     1 #include<iostream>
     2 #include<cstring>
     3 #include<cstdio>
     4 #include<map>
     5 #include<queue>
     6 #include<stack>
     7 #include<algorithm> 
     8 #define ll __int64
     9 #define mod 1 
    10 #define PI acos(-1.0)
    11 using namespace std;
    12 ll a[5];
    13 int t;
    14 int main()
    15 { 
    16      scanf("%d",&t);
    17      for(int i=1;i<=t;i++)
    18 {
    19     scanf("%I64d %I64d %I64d %I64d",&a[0],&a[1],&a[2],&a[3]);
    20     sort(a,a+4);
    21     //cout<<a[0]<<a[1]<<a[2]<<a[3]<<endl;
    22     if(a[0]==0||a[1]==0||a[2]==0||a[3]==0)
    23     cout<<"No"<<endl;
    24     else
    25     {
    26     if(a[0]>a[3]-a[2]-a[1])
    27      cout<<"Yes"<<endl;
    28      else
    29      cout<<"No"<<endl;
    30     }
    31 }
    32     return 0;
    33 }
  • 相关阅读:
    Windows Server 2012 64bit RMAN异机不完全恢复(迁移)
    dbms_jobs vs. dbms_scheduler_jobs
    Migrating from dbms_job to dbms_scheduler
    ORA-12537: TNS:connection closed
    win7 ins 30131 oracle 12c
    Vector源码分析
    LinkedList源码分析
    ArrayList源码分析
    jsp 显示日期
    Spring data redis 使用 pipelined 批量操作
  • 原文地址:https://www.cnblogs.com/hsd-/p/5350549.html
Copyright © 2011-2022 走看看