10223 - How many nodes ?

All about problems in Volume 102. 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
Dmytro Chernysh
Experienced poster
Posts: 146
Joined: Sat Apr 26, 2003 2:51 am

10223 - How many nodes ?

Post by Dmytro Chernysh »

It very easy problem... but why WA?
One has to calucate Cathalan numbers <21 and just print it number.
What is wrong with my algo?
Can somebody publish a few inputs?
Maxim
New poster
Posts: 38
Joined: Tue Aug 27, 2002 12:36 am
Location: Croatia
Contact:

Post by Maxim »

Try with these:

9694845
129644790

Maxim
Dmytro Chernysh
Experienced poster
Posts: 146
Joined: Sat Apr 26, 2003 2:51 am

Thanks!

Post by Dmytro Chernysh »

Thanks!
I have already got AC.
dark man
New poster
Posts: 7
Joined: Fri Mar 26, 2004 11:07 pm
Contact:

10223 -- what is the difference

Post by dark man »

sorry to send the codes but i have failed to find out the difference between these two codes.

this one got AC

#include <stdio.h>

void main()
{
register int i, j;
unsigned long n, arr[32];

for(i = arr[0] = 1; i < 20; i++){
for(j = arr = 0; j < i; j++)
arr += arr[j] * arr;
}

while(scanf("%lu",&n) == 1){
for(i = 1; i < 20; i++){
if(arr == n)
break;
}

printf("%d\n", i);
}
}

this one got WA

#include<stdio.h>

int main()
{
unsigned long A,array[20];
int i;

//array[0] = 1;
array[1] = 1;
array[2] = 2;
array[3] = 5;
array[4] = 14;
array[5] = 42;
array[6] = 132;
array[7] = 429;
array[8] = 1430;
array[9] = 4862;
array[10] = 16796;
array[11] = 58786;
array[12] = 208012;
array[13] = 742900;
array[14] = 267440;
array[15] = 9694845;
array[16] = 35357670;
array[17] = 129644790;
array[18] = 477638700;
array[19] = 1767263190;
//array[20] = 6564120420;

while( scanf("%lu",&A) != EOF )
{
for( i=1 ; i<20 ; i++ )
if( array == A )
{
printf("%d\n",i);
break;
}


}




return 0;
}

sorry again and of course thanks
Try hard . May be you will get the right answer.
Larry
Guru
Posts: 647
Joined: Wed Jun 26, 2002 10:12 pm
Location: Hong Kong and New York City
Contact:

Post by Larry »

Check your numbers, one of them is incorrect.
dark man
New poster
Posts: 7
Joined: Fri Mar 26, 2004 11:07 pm
Contact:

Post by dark man »

Thank you very much. I have checked the numbers for three or four times
but I missed that . I think I should consult with an eye specialist.
(Note : I got AC now )
Try hard . May be you will get the right answer.
Mukit Chowdhury
Learning poster
Posts: 99
Joined: Fri Aug 17, 2012 9:23 pm
Location: Dhaka
Contact:

Re: 10223 - How Many Nodes?

Post by Mukit Chowdhury »

A thing I've notices that,for my code given below, when I give input 1767263190,it should print 19..but it prints nothing... I think that's why I am getting WA... Would anybody tell me please,why it happens for input 1767263190 ???

Code: Select all

Accepted... :)
Last edited by Mukit Chowdhury on Wed Nov 07, 2012 8:37 am, edited 1 time in total.
brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 10223 - How Many Nodes?

Post by brianfry713 »

Don't compare doubles using ==. Instead use something like:
#include <math.h>
if(fabs(c-n)<0.5)
http://acm.uva.es/p/float-in-competition.pdf
Check input and AC output for thousands of problems on uDebug!
Mukit Chowdhury
Learning poster
Posts: 99
Joined: Fri Aug 17, 2012 9:23 pm
Location: Dhaka
Contact:

Re: 10223 - How Many Nodes?

Post by Mukit Chowdhury »

Thanks brianfy713... Got the point... :)
Post Reply

Return to “Volume 102 (10200-10299)”