Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit b4b30a4

Browse files
authored
Create Solution.java
1 parent 03f3aab commit b4b30a4

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
class Solution {
2+
public int numRollsToTarget(int d, int f, int target) {
3+
int[] dp = new int[target + 1];
4+
dp[0] = 1;
5+
for (int i = 1; i <= d; ++i) {
6+
for (int j = target; j >= 1; --j) {
7+
for (int k = 1; k <= f && k <= j; ++k) {
8+
dp[j] = (dp[j] + dp[j - k]) % 1000000007;
9+
}
10+
}
11+
}
12+
return dp[target];
13+
}
14+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /