The Party Arrangement Theory
All submissions for this problem are available.
After years of hardwork, Sheldon finally came out with the result of how different particles are arranged in the universe. To celebrate his success he calls a party. In the party to make others realize how big his experiment was he conducts a small experiment, he gives 'K' peoples in the party 'K' different coloured nims and asks them to put odd number of nim in the sequence then one out of the rest 'K - 1' people puts their odd number of nim in front of the sequence, and this procedure continues until there are 'N' nims in the sequence. Now Sheldon wants the total number of different sequences that can form with this procedure.
for e.g. if there are 'K' = 3 and 'N' = 3 then the possible arrangements are 111 222 333 121 232 313 123 231 312 131 212 323 132 213 321
You have to find the total number of different sequences that can form with the above procedure for the given 'N' and 'K'.
First line contains the of test cases 'T'.
Then 'T' lines follow each containing two integers 'N' and 'K'.
'T' lines corresponding to each test case which contain the number of different sequences that can form with the above procedure for the given 'N' and 'K'.You have to give the answer modulo 10000007.
T <= 10000
0 <= N <= 2^50
1 <= K <= 100
Input: 4 3 3 3 4 4 3 4 5 Output: 15 40 36 360
|Time Limit:||0.24 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, 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, PYP3, CLOJ, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.