11479 - Is this the easiest problem?

All about problems in Volume 114. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

Jorge-ThELaW
New poster
Posts: 1
Joined: Wed Nov 26, 2008 9:59 pm

Re: 11479 - Is this the Easiest Problem?

Post by Jorge-ThELaW » Wed Nov 26, 2008 10:55 pm

How it can be WA????? :

Code: Select all

Removed because accepted!!
Last edited by Jorge-ThELaW on Fri Nov 28, 2008 4:15 pm, edited 1 time in total.

User avatar
shamim
A great helper
Posts: 498
Joined: Mon Dec 30, 2002 10:10 am
Location: Bozeman, Montana, USA

Re: 11479 - Is this the Easiest Problem?

Post by shamim » Thu Nov 27, 2008 9:05 am

Change the data type from long to long long and you will get AC :wink:

This is due to large values of sides whose sum wont fit in 32 bit signed integer.

lnr
Experienced poster
Posts: 142
Joined: Sat Jun 30, 2007 2:52 pm
Location: Dhaka,Bangladesh

Re: 11479 - Is this the Easiest Problem?

Post by lnr » Thu Jul 09, 2009 12:14 am

Can anyone give some special input output?
input:

Code: Select all

20
3 6 -1
5 3 5
6 2 9
1 2 7
0 9 3
6 0 6
2 6 1
8 7 9
2 0 2
3 7 5
9 2 2
8 9 7
3 6 1
2 9 3
1 9 4
7 8 4
5 0 3
6 1 0
6 3 2
0 6 1
output:

Code: Select all

Case 1: Invalid
Case 2: Isosceles
Case 3: Invalid
Case 4: Invalid
Case 5: Invalid
Case 6: Invalid
Case 7: Invalid
Case 8: Scalene
Case 9: Invalid
Case 10: Scalene
Case 11: Invalid
Case 12: Scalene
Case 13: Invalid
Case 14: Invalid
Case 15: Invalid
Case 16: Scalene
Case 17: Invalid
Case 18: Invalid
Case 19: Invalid
Case 20: Invalid
Accepted.

shorojini
New poster
Posts: 8
Joined: Sat Aug 16, 2008 8:14 am

11479 pls pls pls help

Post by shorojini » Sat Oct 24, 2009 8:13 pm

#include<iostream>
using namespace std;
int main() {

long long a, b, c, n,i;
cin>>n;

for(i=1;i<=n;i++)
{

cin>>a>>b>>c;

if((a<=0||b<=0||c<=0)||((b+c)<=a)||((a+c)<=b)||((a+b)<=c))
cout<<"Case "<<i<<": "<<"Invalid\n";
else
{

if((a==b==c))
cout<<"Case "<<i<<": "<<"Equilateral\n";

else if((a==b)||(b==c)||(c==a))
cout<<"Case "<<i<<": "<<"Isosceles\n";

else
cout<<"Case "<<i<<": "<<"Scalene\n";

}

}
return 0;
}

pls tell me where is the wrong? why it is wrong ans. pls pls pls

coze
New poster
Posts: 26
Joined: Tue Nov 27, 2007 7:56 am
Location: Japan

Re: 11479 pls pls pls help

Post by coze » Sat Oct 24, 2009 8:45 pm

Try the following input:
Input

Code: Select all

1
3 3 3
Output

Code: Select all

Case 1: Equilateral

Code: Select all

if (a == b == c)
is not equal to

Code: Select all

if (a == b && b == c)
Hope it helps.

shorojini
New poster
Posts: 8
Joined: Sat Aug 16, 2008 8:14 am

Re: 11479 pls pls pls help

Post by shorojini » Fri Oct 30, 2009 1:03 pm

thanks coz 4 ur great help. i got accepted. i have started acm. and i have no help. will u pls give me ur mail number. so i will be able to share my probs.it is my request.
now , will u just tell me why (a==b==c) is not right. it will be great help.

wawa
New poster
Posts: 5
Joined: Thu Dec 16, 2010 8:17 am

Re: 11479 - Is this the Easiest Problem?

Post by wawa » Mon Dec 20, 2010 4:48 pm

Code: Select all

#include <iostream>
using namespace std;
int main()
{
	long long N, a, b, c;
	cin >> N;
	for (long long i = 0; i < N; i++)
	{
		cin >> a >> b >> c;
		if ((a + b) <= c || (a + c) <= b || (b + c) <= a)
			cout << "Case " << i + 1 << ": Invalid" << endl;
		else if ((a == b) && (a == c))
			cout << "Case " << i + 1 << ": Equilateral" << endl;
		else if ((a == b) || (a == c) || (a == b))
			cout << "Case " << i + 1 << ": Isosceles" << endl;
		else
			cout << "Case " << i + 1 << ": Scalene" << endl;
	}
	return 0;
}
Why is it WA?????? :evil:
plz help...~!!! :-?

asif_iut
New poster
Posts: 16
Joined: Mon Nov 01, 2010 8:08 am

Re: 11479 - Is this the Easiest Problem?

Post by asif_iut » Wed Dec 22, 2010 9:30 am

else if ((a == b) || (a == c) || (a == b))
what is the difference between the first and the last condition??

kissu parina
New poster
Posts: 19
Joined: Thu May 20, 2010 8:58 am

Re: 11479 - Is this the Easiest Problem?

Post by kissu parina » Sat Feb 05, 2011 4:31 pm

long data type is enough for this problem. :D
one day...

hotovaga
New poster
Posts: 4
Joined: Mon Nov 29, 2010 9:35 pm

Re: 11479 - Is this the Easiest Problem?

Post by hotovaga » Mon Feb 21, 2011 9:02 am

Where is the problem in my code? getting WA..
help me pls..

Code: Select all

got AC

du_loser
New poster
Posts: 1
Joined: Mon May 30, 2011 12:41 pm

Re: 11479 - Is this the Easiest Problem?

Post by du_loser » Mon May 30, 2011 1:00 pm

getting wa :cry:

Code: Select all

#include<stdio.h>
int main(){
	long long int c,tc,a[3],i,j,t;
	scanf("%lld",&tc);
	for(c=1;c<=tc;c++){
		scanf("%lld%lld%lld",&a[0],&a[1],&a[2]);
	for(i=0;i<2;i++){
		for(j=0;j<2-i;j++){
			if(a[j]<a[j+1]){
				t=a[j];
				a[j]=a[j+1];
				a[j+1]=t;
			}
		}
	}
	printf("Case %lld: ",c);
	if((a[0]<=(a[1]+a[2]))&&a[0]>0&&a[1]>0&&a[2]>0){
		if(a[0]==a[1]&&a[1]==a[2])
			printf("Equilateral\n");
		else if(a[0]==a[1]||a[1]==a[2]||a[2]==a[0])
			printf("Isosceles\n");
		else
			printf("Scalene\n");
	}
	else printf("Invalid\n");
    }
return 0;
}

helloneo
Guru
Posts: 516
Joined: Mon Jul 04, 2005 6:30 am
Location: Seoul, Korea

Re: 11479 - Is this the Easiest Problem?

Post by helloneo » Wed Jun 01, 2011 5:32 pm

Try this case..

Code: Select all

1
1 2 3

My output is..

Code: Select all

Case 1: Invalid

ez0545
New poster
Posts: 1
Joined: Tue Jul 26, 2011 1:36 am

Re: 11479 - Is this the Easiest Problem?

Post by ez0545 » Wed Jul 27, 2011 11:50 am

Code: Select all

 got acc


can anyone please tell me whats wrong with this code??? I am getting wrong answer every time.

Help Me
New poster
Posts: 1
Joined: Sat Dec 03, 2011 9:03 pm
Location: Chittagong
Contact:

Re: 11479 - Is this the Easiest Problem?

Post by Help Me » Thu Dec 08, 2011 4:09 am

What is the problem??? Why it Wrong answer?




#include<stdio.h>
#include<stdlib.h>


int comp(const void *a, const void *b)
{
return (*(long int *)a)-(*(long int *)b);
}



int main()
{
long int t,p,x,y,z,ary[10000],k,temp,max,small,mid,l;
scanf("%ld",&t);
for(p=1;p<=t;p++)
{
scanf("%ld%ld%ld",&x,&y,&z);
ary[1]=x;
ary[2]=y;
ary[3]=z;

qsort(ary,4,sizeof(ary[1]),comp);

small=ary[1];
mid=ary[2];
max=ary[3];
if((small+mid)<=max)
printf("Case %ld: Invalid\n",p);
else if(x==y==z)
printf("Case %ld: Equilateral\n",p);
else if((x==y)||(x==z)||(y==z))
printf("Case %ld: Isosceles\n",p);

else
printf("Case %ld: Scalene\n",p);

}

return 0;
}

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 11479 - Is this the Easiest Problem?

Post by brianfry713 » Fri Jan 13, 2012 2:52 am

You're sorting an array of size 4 that should only be of size 3. Think of what happens with negatives.
Check input and AC output for thousands of problems on uDebug!

Post Reply

Return to “Volume 114 (11400-11499)”