CA Loves Stick

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

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.
1≤T≤1000, 0≤a,b,c,d≤263−1
 
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

题意:给你四条边,判断是否能组成一个四边形

题解:任意三边之和大于第四边(第四边为最大边)   a+b+c>=d;  转化为减法a+b>=d-c;

注意:1、三个数相加可能超64位    2、如果边为0 就输出no

#include<stdio.h>
#include<string.h>
#include<vector>
#include<map>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<math.h>
#include<algorithm>
#define LL long long
#define PI atan(1.0)*4
#define DD double
#define MAX 450
#define mod 10003
#define INF 0x3f3f3f3f
using namespace std;
unsigned __int64 s[6];
int main()
{
int t;
unsigned __int64 n,m,a,b,c,d;
scanf("%d",&t);
while(t--)
{
scanf("%I64u%I64u%I64u%I64u",&a,&b,&c,&d);
if(a==0||b==0||c==0||d==0)
{
printf("No\n");
continue;
}
s[0]=a;s[1]=b;s[2]=c;s[3]=d;
sort(s,s+4);
if(s[1]+s[0]>=s[3]-s[2])
printf("Yes\n");
else
printf("No\n");
}
return 0;
}

  

hdu 5655 CA Loves Stick的更多相关文章

  1. HDU 5655 CA Loves Stick 水题

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5656 CA Loves Stick Accepts: 381   Submissions: 3204 ...

  2. hdu 5656 CA Loves GCD(n个任选k个的最大公约数和)

    CA Loves GCD  Accepts: 64  Submissions: 535  Time Limit: 6000/3000 MS (Java/Others)  Memory Limit: 2 ...

  3. HDU 5656 CA Loves GCD 01背包+gcd

    题目链接: hdu:http://acm.hdu.edu.cn/showproblem.php?pid=5656 bc:http://bestcoder.hdu.edu.cn/contests/con ...

  4. HDU 5656 CA Loves GCD dp

    CA Loves GCD 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5656 Description CA is a fine comrade w ...

  5. HDU 5656 CA Loves GCD (数论DP)

    CA Loves GCD 题目链接: http://acm.hust.edu.cn/vjudge/contest/123316#problem/B Description CA is a fine c ...

  6. 数学(GCD,计数原理)HDU 5656 CA Loves GCD

    CA Loves GCD Accepts: 135 Submissions: 586 Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 2621 ...

  7. HDU 5656 ——CA Loves GCD——————【dp】

    CA Loves GCD Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)To ...

  8. HDU 5658 CA Loves Palindromic(回文树)

    CA Loves Palindromic Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/O ...

  9. hdu 5656 CA Loves GCD

    CA Loves GCD Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)To ...

随机推荐

  1. mysql免安装版安装

    MySQL是一个小巧玲珑但功能强大的数据库,目前十分流行.但是官网给出的安装包有两种格式,一个是msi格式,一个是zip格式的.很多人下了zip格式的解压发现没有setup.exe,面对一堆文件一头雾 ...

  2. BZOJ 3668 起床困难综合症

    按位贪心. #include<iostream> #include<cstdio> #include<cstring> #include<algorithm& ...

  3. (转) Python Generators(生成器)——yield关键字

    http://blog.csdn.net/scelong/article/details/6969276 生成器是这样一个函数,它记住上一次返回时在函数体中的位置.对生成器函数的第二次(或第 n 次) ...

  4. (转)Spark 算子系列文章

    http://lxw1234.com/archives/2015/07/363.htm Spark算子:RDD基本转换操作(1)–map.flagMap.distinct Spark算子:RDD创建操 ...

  5. xp关不了机

    自己测试:按第2点的设置既可成功1.点“开始→设置→控制面板→电源选项→高级电源管理”,如果你的机器支持高级电源管理功能,则选中“启用高级电源管理支持”:2.单击“开始”,并运行“regedit”,然 ...

  6. ecshop 优化_将商品详情页goods.php重命名为shangpin.php

    有人说,将商品详情页的文件名 goods.php 改一个名字,对百度收录会有帮助,也许吧,这里不讨论是否有帮助,这里只讲解如何重命名. 例如:我们将 goods.php 改为 shangpin.php ...

  7. HDU 产生冠军 2094

    解题思路:这题重在分析,可能你知道的越多,这题想得越多,什么并查集,什么有向图等. 事实是,我们会发现,只要找到一个,并且仅有一个的入度为0的点,说明可以找出   冠军.若入度为0的点一个都没有,说明 ...

  8. HALCON基础知识

    HALCON 1. 语法范式 Syntax Style 1.1. 基本格式 1.1.1. 算子格式 算子(输入图像参数:输出图像参数:输入控制参数:输出控制参数) 其中四个参数任意一个可以为空 e.g ...

  9. Javascript模块化编程(三):require.js的用法 (转)

    转自:http://my.oschina.net/u/1390066/blog/213769 一.为什么要用require.js? 最早的时候,所有Javascript代码都写在一个文件里面,只要加载 ...

  10. python 对数函数

    from math import logfrom math import e print e #自然对数print log(e) #log函数默认是以e为底print log(100,10) #以10 ...