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)
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)
T T testcases follow. Each testcase contains four integers a,b,c,d a,b,c,d in a line, denoting the length of sticks.
1≤T≤1000, 0≤a,b,c,d≤263−1 1≤T≤1000, 0≤a,b,c,d≤263−1
2 1 1 1 1 1 1 9 2
Yes No
给你四条边让你计算能否在组成一个四边形,当时题目意思没有看懂,后来考完才知道的,由于边的长度比较大,所以用long long存储,在判断时不能用加,只能用减,因为long long相加可能会超过long long的存储范围,出现错误。#include<stdio.h> #include<string.h> #include<algorithm> using namespace std; int main() { int t; scanf("%d",&t); while(t--) { long long int i,p[20]; for(i=0;i<4;i++) scanf("%lld",&p[i]); sort(p,p+4); if(p[0]==0) { printf("No\n");continue; } if(p[3]-p[2]-p[1]<p[0]) printf("Yes\n"); else printf("No\n"); } }