码迷,mamicode.com
首页 > 其他好文 > 详细

HDU 5655 CA Loves Stick 水题

时间:2016-04-08 21:33:37      阅读:209      评论:0      收藏:0      [点我收藏+]

标签:

题目链接:

http://acm.hdu.edu.cn/showproblem.php?pid=5656

CA Loves Stick

 

 Accepts: 381   Submissions: 3204

 Time Limit: 2000/1000 MS (Java/Others)     Memory Limit: 262144/262144 K (Java/Others)

问题描述

CA喜欢玩木棍。

有一天他获得了四根木棍,他想知道用这些木棍能不能拼成一个四边形。(四边形定义:https://en.wikipedia.org/wiki/Quadrilateral

输入描述

第一行TT,表示有TT组数据。

接下来TT组数据,每组数据包含四个整数a,b,c,da,b,c,d,分别为四根木棍的长度。

1 \le T \le 1000,~0 \le a,b,c,d \le 2^{63}-11≤T≤1000, 0≤a,b,c,d≤2?63??−1

输出描述

对于每个数据,如果能拼成一个四边形,输出“Yes”;否则输出“No”(不包括双引号)。

输入样例

2

1 1 1 1

1 1 9 2

输出样例

Yes

No

 

题解:

-2^63:  xb1000...0(63个0) ,即 -0;(LL)1<<63

   0:  xb0000...0(64个0),即+0;

  最小三边和大于最大边即可构成4边形

  但数据很多会爆,所以要做些处理

代码:

技术分享
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;

typedef long long LL;
const LL t_63 = ((LL)1 << 63);
LL a[11];


int main() {
    int tc;
    scanf("%d", &tc);
    LL x = 0;
    while (tc--) {
        for (int i = 0; i < 4; i++) scanf("%lld", a + i);
        sort(a, a + 4);
        if (a[0]>0 && a[0] - t_63 + a[1]>a[3] - a[2] - t_63) {
            printf("Yes\n");
        }
        else printf("No\n");
    }
    return 0;
}
View Code
技术分享
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;

typedef long long LL;
LL a[11];


int main() {
    int tc;
    scanf("%d", &tc);
    while (tc--) {
        for (int i = 0; i < 4; i++) scanf("%lld", a + i);
        sort(a, a + 4);
        if (a[0]>0&&a[0]>a[3] - a[2]-a[1]) {
            printf("Yes\n");
        }
        else printf("No\n");
    }
    return 0;
}
View Code

HDU 5655 CA Loves Stick 水题

标签:

原文地址:http://www.cnblogs.com/fenice/p/5369872.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!