Skip to content

Commit

Permalink
Add solution
Browse files Browse the repository at this point in the history
  • Loading branch information
RikuPutkinen committed Sep 14, 2023
1 parent f90f6c3 commit b5de175
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
3 changes: 3 additions & 0 deletions dynamic-programming/dice-combinations/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Dice Combinations

Problem page <https://cses.fi/problemset/task/1633/>
25 changes: 25 additions & 0 deletions dynamic-programming/dice-combinations/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include <iostream>

using namespace std;

int main(){
int M = 1000000007;
int n{};
cin >> n;
int ready[1000001];
ready[0] = 1;

for (int i = 1; i <= n; i++){
ready[i] = 0;
for (int j = 0; j <= 6; j++){
if (i - j >= 0){
ready[i] += ready[i-j];
ready[i] %= M;
}
}
}

cout << ready[n] << "\n";

return 0;
}

0 comments on commit b5de175

Please sign in to comment.