ParenthesisProblem code: DCE03 |
The captain of TITANIC is a mathematics freak. He has recently been given a problem that he is unable to solve. And he has asked your help to solve it.
There are n numbers in a given expression.
X1 X2 X3 .... Xn
What is the number of ways to put parenthesis in the expression.
For n=4, the different ways are
(((x1.x2).x3).x4) ((x1.x2).(x3.x4)) (x1.((x2.x3).x4)) (x1.(x2.(x3.x4))) ((x1.(x2.x3)).x4)Hence the required answer would be 5.
Input
The first line contains the number of test cases t <=10. Each of the next t lines contain single integers <=1000 denoting n.
Output
Display t lines containg the number of ways to put parenthesis in the expression of length n modulo 10000.
Example
Input: 2 4 5 Output: 5 14
| Author: | uploader0 |
| Date Added: | 14-10-2009 |
| Time Limit: | 8 sec |
| Source Limit: | 50000 Bytes |
| Languages: | ADA, ASM, BASH, BF, C, C99 strict, CAML, CLOJ, CLPS, CPP 4.0.0-8, CPP 4.3.2, CS2, D, F#, FORT, GO, HASK, ICK, ICON, JAR, JAVA, JS, LISP clisp, LISP sbcl, LUA, NEM, NICE, PAS fpc, PAS gpc, PERL, PERL6, PHP, PIKE, PRLG, PYTH, PYTH 3.1.2, RUBY, SCALA, SCM guile, SCM qobi, ST, TEXT, WSPC |
Comments

Fetching successful submissions

Please ignore any submissions
Please ignore any submissions made by Sailesh Mittal.
Could you please check your
Could you please check your output file. I am quite sure my algorithm is correct but I am constantly getting WA.
The output is correct.
The output is correct.
what is the answer for n=1?
what is the answer for n=1?
output for n=1 is 1
output for n=1 is 1
Can you give us one or two
Can you give us one or two more sample cases.??
Because as far as i see my logic is quite right.
eg for 6 or 7..
I will help us understand problem well..
@admin some test cases plz
@admin
some test cases plz
One more test case- input:
One more test case-
input: 7
output: 132
Can any1 tel me wat wud b o/p
Can any1 tel me wat wud b o/p 4 n = 1000?