10007  Count the Trees
Moderator: Board moderators

 Experienced poster
 Posts: 145
 Joined: Sat Feb 23, 2002 2:00 am
 Location: Paris, France
 Contact:

 Experienced poster
 Posts: 145
 Joined: Sat Feb 23, 2002 2:00 am
 Location: Paris, France
 Contact:
Larry,
Obvously the formula you have given is wrong,
I think you've made a typo.
Well the right formula is
At least these are the values in the sample output of problem 10007
( if we assume that the input value is N ).
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 ) !
( if we assume that the input value is N ).
one more solution in java for 10007
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.
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.

 Guru
 Posts: 647
 Joined: Wed Jun 26, 2002 10:12 pm
 Location: Hong Kong and New York City
 Contact:
Java is allowed on most ACM competitions.. though that's actually up to each site..
Check out http://www.algorithmist.com !
BigInteger
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.
I just said that the standard Java class
java.math.BigInteger
is not allowed by the Online Judge of this site.

 Guru
 Posts: 647
 Joined: Wed Jun 26, 2002 10:12 pm
 Location: Hong Kong and New York City
 Contact:
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..)
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..)
Check out http://www.algorithmist.com !
10007
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?
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?

 Guru
 Posts: 1080
 Joined: Thu Dec 19, 2002 7:37 pm
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
however, problem was in my code. i corrected it and first got TLE. then after some optimization, i got AC

 Guru
 Posts: 1080
 Joined: Thu Dec 19, 2002 7:37 pm

 New poster
 Posts: 9
 Joined: Fri Nov 03, 2006 1:25 am
 Location: Canada