Cups and Balls
All submissions for this problem are available.
Ram is playing a game where there are exactly N cups numbered 1 to N in a row in front of him and he has balls numbered from 1 to N with him. In this game his opponent gives him a number K(0 <= K <= N), and Ram has to arrange the the balls in the cup (1 ball per cup) such that he gets exactly k good cups.
If the balls arranged in the row are numbered a1, a2, a3, .... an then a cup is good if |ai - i| = 1.
Ram is a mathematician so, he is thinking the total number of ways he can arrange the balls in the cups such that he get K good positions. Help ram in the problem. As the result might be large, output the ans mod 10^9 + 7.
The first line would contain the number of test cases T.
Every test case consist of two space separated values N and K.
For every test case output the single Integer, the number of ways Ram can arrange exactly N balls in the cups such that he gets K good positions mod 10^9 + 7 (1000000007)
1 <= T <= 201 <= N <= 1000 0 <= K <= N
|Time Limit:||2 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.5, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, CLOJ, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.