991 - Safe Salutations

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

Moderator: Board moderators

Post Reply
abhi
Learning poster
Posts: 94
Joined: Fri Nov 25, 2005 7:29 pm

991 - Safe Salutations

Post by abhi » Mon Nov 20, 2006 2:58 pm

hi can anybody tell me why i get WA

Code: Select all

# include <stdio.h>

int main()
{
	int n,i;
	int arr[20];

	arr[0]=0;
	arr[1]=0;
	
	for(i=2;i<=10;i++)
	{
		arr[i]=((i-1)*(i-1))+arr[i-1];
	}

	while(scanf("%d",&n)==1)
	{
		printf("%d\n\n",arr[n]);
	}
return 0;
}


User avatar
little joey
Guru
Posts: 1080
Joined: Thu Dec 19, 2002 7:37 pm

Post by little joey » Mon Nov 20, 2006 3:13 pm

Because your formula is not correct. Your answers for 1 and 2 pairs are wrong, which can be easily verified if you make the drawings.

PS. Put the problem title in the subject line too if you create a new thread.

zxul767
New poster
Posts: 11
Joined: Sat Nov 11, 2006 1:39 am

Post by zxul767 » Sat Oct 13, 2007 6:18 am

I have written a solution for this problem, and I'm sure the formula I use is correct, yet I keep on getting WA on the new uva judge site.

Here is my code:
Code removed...
Can anyone tell me or provide a hint as to why I keep on getting WA?[/quote]
Last edited by zxul767 on Wed Oct 17, 2007 5:43 pm, edited 1 time in total.

Jan
Guru
Posts: 1334
Joined: Wed Jun 22, 2005 10:58 pm
Location: Dhaka, Bangladesh
Contact:

Post by Jan » Sat Oct 13, 2007 10:12 am

Print a blank line between cases. not after each case.
Ami ekhono shopno dekhi...
HomePage

zxul767
New poster
Posts: 11
Joined: Sat Nov 11, 2006 1:39 am

Shouldn't it present PE instead of WA?

Post by zxul767 » Sat Oct 13, 2007 7:12 pm

I had already thought about what you told me Jan, so I removed the last two newline chars and submitted it back, but still got WA. After a while, I decided to remove only the very last newline char and got AC.

I think the judging for this problem must be corrected, since it should give PE as verdict in this case, not WA.

Anyway, thanks for your help Jan!

mukeshtiwari
Learning poster
Posts: 63
Joined: Tue Mar 07, 2006 6:51 pm
Location: india

Post by mukeshtiwari » Wed Oct 17, 2007 8:57 pm

hello abhi .....
this problem is related to a well known number series ( binary tree enumartion ).
hope it is helpful .

Post Reply

Return to “Volume 9 (900-999)”