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 74b7ea4

Browse files
authored
Update Solution.java
1 parent d18e0fc commit 74b7ea4

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

‎solution/1155.Number of Dice Rolls With Target Sum/Solution.java‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ public int numRollsToTarget(int d, int f, int target) {
44
dp[0][0] = 1;
55
for (int i = 1; i <= d; ++i) {
66
for (int j = 1; j <= target; ++j) {
7+
// j 大于当前所有骰子的最大和,不可能满足条件
8+
if (j > i * f) {
9+
break;
10+
}
711
for (int k = 1; k <= f && k <= j; ++k) {
812
dp[i][j] = (dp[i][j] + dp[i - 1][j - k]) % 1000000007;
913
}

0 commit comments

Comments
(0)

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