zoukankan      html  css  js  c++  java
  • HDU 5655 CA Loves Stick 水题

    题目链接:

    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≤263​−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
    ");
            }
            else printf("No
    ");
        }
        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
    ");
            }
            else printf("No
    ");
        }
        return 0;
    }
    View Code
  • 相关阅读:
    hihocoder #1407 : 后缀数组二·重复旋律2
    后缀数组基本问题QAQ
    hihocoder #1403 : 后缀数组一·重复旋律
    20170116小测233
    HDU 4779:Tower Defense
    BZOJ 2563: 阿狸和桃子的游戏
    Codeforces 460D. Little Victor and Set
    Codeforces 297C. Splitting the Uniqueness
    BZOJ 2565: 最长双回文串
    Manacher--雾窗寒对遥天暮,暮天遥对寒窗雾
  • 原文地址:https://www.cnblogs.com/fenice/p/5369872.html
Copyright © 2011-2022 走看看