some dp problems
This commit is contained in:
22
CSES - CSES Problem Set/Dice_Combinations.cpp
Normal file
22
CSES - CSES Problem Set/Dice_Combinations.cpp
Normal file
@@ -0,0 +1,22 @@
|
||||
// Dice Combinations
|
||||
|
||||
#include<bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
using ll = long long;
|
||||
|
||||
const ll N = 1e6;
|
||||
const ll MOD = 1e9 + 7;
|
||||
|
||||
ll ways[N + 1];
|
||||
|
||||
int main() {
|
||||
ll n; cin >> n;
|
||||
ways[0] = 1;
|
||||
for (ll i = 1; i <= n; i++) {
|
||||
for (ll j = 1; j <= 6 && j <= i; j++) {
|
||||
ways[i] = (ways[i] + (ways[i - j])) % MOD;
|
||||
}
|
||||
}
|
||||
cout << ways[n];
|
||||
}
|
||||
Reference in New Issue
Block a user