标签:codeforces 水题
给出四条边,问是否可以取三条边组成一个三角形,如果不行的话可否组成一个退化的三角形(两边之和等于第三边)
水题,啥都不说枚举即可。
#include <set>
#include <map>
#include <queue>
#include <math.h>
#include <vector>
#include <string>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <iostream>
#include <cctype>
#include <algorithm>
#include <time.h>
#define eps 1e-10
#define pi acos(-1.0)
#define inf 107374182
#define inf64 1152921504606846976
#define lc l,m,tr<<1
#define rc m + 1,r,tr<<1|1
#define zero(a) fabs(a)<eps
#define iabs(x) ((x) > 0 ? (x) : -(x))
#define clear1(A, X, SIZE) memset(A, X, sizeof(A[0]) * (min(SIZE,sizeof(A))))
#define clearall(A, X) memset(A, X, sizeof(A))
#define memcopy1(A , X, SIZE) memcpy(A , X ,sizeof(X[0])*(SIZE))
#define memcopyall(A, X) memcpy(A , X ,sizeof(X))
#define max( x, y ) ( ((x) > (y)) ? (x) : (y) )
#define min( x, y ) ( ((x) < (y)) ? (x) : (y) )
using namespace std;
bool judgeTri(int a,int b,int c)
{
if(a+b>c&&iabs(a-b)<c)return true;
return false;
}
bool judgeSeg(int a,int b,int c)
{
if(a+b==c)return true;
return false;
}
int num[5],n=4;
int main()
{
for(int i=0;i<n;i++)
{
scanf("%d",&num[i]);
}
bool flat1=false,flat2=false;
for(int i=0;i<n;i++)
{
for(int j=i+1;j<n;j++)
{
for(int k=j+1;k<n;k++)
{
if(judgeTri(num[i],num[j],num[k])||judgeTri(num[i],num[k],num[j])||judgeTri(num[k],num[j],num[i]))flat1=true;
if(judgeSeg(num[i],num[j],num[k])||judgeSeg(num[i],num[k],num[j])||judgeSeg(num[k],num[j],num[i]))flat2=true;
}
}
}
if(flat1)
{
puts("TRIANGLE");
}
else if(flat2)
{
puts("SEGMENT");
}
else puts("IMPOSSIBLE");
return 0;
}
Codeforces Beta Round #6 (Div. 2 Only) A. Triangle
标签:codeforces 水题
原文地址:http://blog.csdn.net/lin375691011/article/details/43868219