Page 2 of 3

Posted: Sat Nov 22, 2003 6:24 pm
by ..
Oh thx~~ :D
I forget Catalan number completely~~ :oops:

Posted: Thu Feb 05, 2004 6:13 pm
by alex[LSD]
Whoa!
I was a about to start coding that F(0)*F(N-1)+F(1)*F(N-2)+... solution. But when you see that F(N) = C(N,2N) - C(N+1,2N) = 2N!/(N+1)!N!
... you just dont want to do it.
Thanks, I will remember it now...

Posted: Mon Jul 12, 2004 1:12 pm
by Julien Cornebise
Hi

I tried to use the nice solution mentionned above (after having found it by myself). Nevertheless, still TLE :(
Is it that my BigInteger routines are *really* slow (that alas might be), or is there a hint to accelerate the calculation ?

Thank you !

Posted: Mon Jul 12, 2004 6:06 pm
by Larry
Ya, you'll need to optimize your BigInt a little, since I did a very trivial implementation, and in Java, and it still AC'ed (though with a slow time..) It's either that or you may not be handling the IO correctly..

Posted: Thu Jul 15, 2004 9:32 am
by Julien Cornebise
Thanks ! I'll try that :)
Btw, are Java's BigInteger class allowed in regional contests and/or in world finals ?

Posted: Tue Feb 15, 2005 7:14 pm
by Sedefcho
Larry,

Obvously the formula you have given is wrong,
I think you've made a typo.

Well the right formula is

Code: Select all

( 2*N ) !   /  (N+1 ) !  
At least these are the values in the sample output of problem 10007
( if we assume that the input value is N ).

one more solution in java for 10007

Posted: Tue Feb 15, 2005 8:00 pm
by Sedefcho
The standard Java class BigInteger is not allowed by
the Online Judge, I do not know if it is acceptable in
ACM or other programming contests.

By the way in Java I get ACC on this problem in
approximately 0.25 secs.

If someone needs some hints
( especially if this someone attacks that
problem in Java ), I will be happy to give him
some hints.

Posted: Tue Feb 15, 2005 9:06 pm
by Larry
Java is allowed on most ACM competitions.. though that's actually up to each site..

BigInteger

Posted: Wed Feb 16, 2005 1:09 am
by Sedefcho
Sure, Java is allowed.

I just said that the standard Java class
java.math.BigInteger
is not allowed by the Online Judge of this site.

Posted: Wed Feb 16, 2005 3:15 am
by Larry
Each site as in each regional contest site, I meant.

Java here is version 1.2, where BigInteger is implemented in 1.3 and later, hence the lack of support. It isn't that that the class that is specifically banned. (As far as I understand it..)

10007

Posted: Fri Sep 15, 2006 12:36 pm
by Donotalo
i'm having problem with generating catalan number efficiently. here is what i did:

Catalan(n+1) = (2 * (2n + 1) * Catalan(n)) / (n + 2)

it gives me some wrong catalan numbers since the numerator may not properly divisible by (n + 2). any solution to this problem?

Posted: Fri Sep 15, 2006 1:39 pm
by little joey
That is not the correct formula. Try again.

Posted: Fri Sep 15, 2006 2:54 pm
by Donotalo
that is actually valid equation. source: http://mathworld.wolfram.com/CatalanNumber.html

however, problem was in my code. i corrected it and first got TLE. then after some optimization, i got AC :)

Posted: Fri Sep 15, 2006 3:25 pm
by little joey
Duh. Of course you're right. I was looking in the wrong place in my source code... :oops:

Posted: Fri Nov 03, 2006 1:28 am
by Scottathon
Can someone post some input and output?
My program passes the sample input, but I keep getting wrong answer.

Thanks.