天天看点

joj1817

joj1817
1817: Triangle

Result TIME Limit MEMORY Limit Run Times AC Times JUDGE
joj1817
5s 8192K 2665 747 Standard

2nd JOJ Cup Online VContest Problem

Given three integers a, b and c(|a|, |b|, |c|<10000), determine if they can compose a valid triangle. If so, further determine which kind of the triangle it is.

Input Specification

The input consists of several lines, each of which contains three integers a, b and c.

Output Specification

For each group of a b and c, first print "Case K:", a space, and then one of the following four lines:

is not a valid triangle.

is a sharp triangle.

is a right triangle.

is a blunt triangle.

corresponding to your determinant, where K is the number of the test cases starting from 1.

Sample Input

3 4 5

3 3 3

1 2 3

3 4 6

Sample Output

Case 1: is a right triangle.

Case 2: is a sharp triangle.

Case 3: is not a valid triangle.

Case 4: is a blunt triangle.

This problem is used for contest: 104  167  181  185 

Submit / Problem List / Status / Discuss

Problem Set with Online Judge System Version 3.12

Jilin University

Developed by skywind, SIYEE

#include<cstdio>

int u,v,m;

bool istriangle(int i,int j,int s)

{

    if(i+j>s&&i+s>j&&j+s>i)return true;

    return false;

}

bool isrighttriangle()//直角

{

    if(u==v+m||v==u+m||m==u+v)return true;

    return false;

}

bool issharptriangle()//锐角

{

    if(u+v>m&&u+m>v&&v+m>u)return true;

    return false;

}

bool isblunttriangle()//钝角

{

    if(u>v+m||v>u+m||m>u+v)return true;

    return false;

}

int main()

{

    int n=0;

    int i,j,s;

    while(scanf("%d%d%d",&i,&j,&s)==3)

    {

        n++;

        u=i*i;v=j*j; m=s*s;

        if(!istriangle(i,j,s))

        printf("Case %d: is not a valid triangle.\n",n);

        else if(isrighttriangle())

        printf("Case %d: is a right triangle.\n",n);

        else if(issharptriangle())

        printf("Case %d: is a sharp triangle.\n",n);

        else

        printf("Case %d: is a blunt triangle.\n",n);

    }

    return 0;

}

上一篇: joj1012
下一篇: 1995: Energy