Rating changes for last rounds are temporarily rolled back. They will be returned soon. ×

What makes you so much skillful in iterative dp?

Revision en1, by question_id, 2015-11-18 06:46:59

I am very much trying to understand iterative dp but not getting it comfortable. I've done many paperwork. For example: For the following problem I can design a solution which run on O(n*k*S) which is not efficient. Can you help me on this that how to understand, find out solution in iterative dp? I can design recursive dp bt can't transform it in iterative dp.

Problem: LightOj-1145

You have N dices; each of them has K faces numbered from 1 to K. Now you have arranged the N dices in a line. You can rotate/flip any dice if you want. How many ways you can set the top faces such that the summation of all the top faces equals S?

Now you are given N, K, S; you have to calculate the total number of ways. Input

Input starts with an integer T (≤ 25), denoting the number of test cases.

Each case contains three integers: N (1 ≤ N ≤ 1000), K (1 ≤ K ≤ 1000) and S (0 ≤ S ≤ 15000). Output

For each case print the case number and the result modulo 100000007.

Sample Input:

5

1 6 3

2 9 8

500 6 1000

800 800 10000

2 100 10

Sample Output:

Case 1: 1

Case 2: 7

Case 3: 57286574

Case 4: 72413502

Case 5: 9

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English question_id 2015-11-18 06:46:59 1243 Initial revision (published)