Page 4 of 4

### Re: 11479 - Is this the easiest problem?

Posted: Mon Sep 15, 2014 3:20 pm
Try input in this thread first.
lnr wrote:Can anyone give some special input output?
input:

Code: Select all

``````1
9 2 2``````
output:

Code: Select all

``Case 1: Invalid``
Accepted.
sohel wrote:A triangle is invalid if any side_length <= 0 or (sum of smaller 2 sides <= largest side).
A triangle is scalene if it is valid && all the sides are distinct.
renatov wrote:To check if the sides form a triangle, you should performe 2 tests:

1. See if every input is greater than zero
2. | b - c | < a < b + c
I got accepted and I didn't check if input is negative. Maybe judge doesn't contain negative input

### 11479 - WA

Posted: Sun Jan 11, 2015 11:05 am
I have researched this forums for possible hints to why my code is wrong. But I cannot find any. Could someone please help me?

Code: Select all

``````class Main {

public static void main(String[] args) {
java.util.Scanner in = new java.util.Scanner(System.in);
long[] sides = new long;
long cases = in.nextLong();
String triangleType;

for (int i = 1; i <= cases; i++) {

sides = in.nextLong();
sides = in.nextLong();
sides = in.nextLong();

triangleType = "Invalid";

/* Ensure sum of any two sides > third side */
if (sides > 0 && sides > 0 && sides > 0) {
if (sides + sides > sides && sides + sides > sides
&& sides + sides > sides) {
if (sides == sides && sides == sides) {
/* Check for equilateral triangle */
triangleType = "Equilateral";
} else if (sides != sides && sides != sides && sides != sides) {
/* Check for scalene triangle */
triangleType = "Scalene";
} else {
/* Check for isoceles triangle */
triangleType = "Isosceles";
}
}
System.out.println("Case " + i + ": " + triangleType);
}
}
}
}``````

### Re: 11479 - Is this the easiest problem?

Posted: Tue Jan 13, 2015 12:21 am
Next time post in the existing thread and use code blocks.
It looks like you figured it out.

### Re: 11479 - Is this the easiest problem?

Posted: Sat Jan 24, 2015 10:24 am
got WA

Code: Select all

``````#include<stdio.h>

int main()
{
int test_case,i;
long long int a,b,c;

scanf("%d",&test_case);

for(i=1;i<=test_case;i++)
{
scanf("%llu %llu %llu",&a,&b,&c);

if(a>=b+c || b>=a+c || c>=a+b || a<=0 || b<=0 || c<=0)
printf("case %d: Invalid\n",i);
else if(a==b && b==c)
printf("case %d: Equilateral\n",i);
else if(a==b || a==c || b==c || c==a)
printf("case %d: Isosceles\n",i);
else if(a!=b && b!=c)
printf("case %d: Scalene\n",i);
}

return 0;
}``````