The D Problem
All submissions for this problem are available.
You have a chest of drawers, one with many drawers stacked one upon another. These also have a locking system. However, over the time your locks on the drawers has stopped working. This not only enables anyone to access the contents of the drawer but also of the one that is located below it. Thus decreasing the security.
But a remarkable feature is that you can interchange the drawers along with your locks. Since many of your friends have such drawers and they also have lost a few locks you decide to build a software which inputs the number of drawers in the chest and the number of locked and safe drawers required. This should output a single integer telling you in how many patterns can the drawers be arranged to achieve this state.
Each line contains two integers. The first is number of drawers and the second is the number of locked and safe drawers. The inputs should be terminated by two negative numbers in the end. This line should not be processed.
For each line of input produce one line of output containing a single integer denoting in how many ways can the s drawers be arranged out of the n drawers to be secure.
Input: 6 2 6 3 6 4 -1 -1 Output: 16 9 6
|Time Limit:||0.1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, JAVA, PYTH, PYTH 3.6, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, JAR, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, CLOJ, FS|
Fetching successful submissions