Page 1 of 1
10223 - How many nodes ?
Posted: Sat May 03, 2003 4:48 am
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?
Posted: Sun May 04, 2003 11:55 pm
by Maxim
Try with these:
9694845
129644790
Maxim
Thanks!
Posted: Mon May 05, 2003 12:05 am
by Dmytro Chernysh
Thanks!
I have already got AC.
10223 -- what is the difference
Posted: Mon Mar 29, 2004 7:19 pm
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
Posted: Tue Mar 30, 2004 12:02 am
by Larry
Check your numbers, one of them is incorrect.
Posted: Tue Mar 30, 2004 7:44 pm
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 )
Re: 10223 - How Many Nodes?
Posted: Tue Nov 06, 2012 11:57 am
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 ???
Re: 10223 - How Many Nodes?
Posted: Wed Nov 07, 2012 1:54 am
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
Re: 10223 - How Many Nodes?
Posted: Wed Nov 07, 2012 8:36 am
by Mukit Chowdhury
Thanks brianfy713... Got the point...
