Search
 
SCRIPT & CODE EXAMPLE
 

CPP

dice combinations cses solution

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

#define MAXN 1000001
#define MOD 1000000007

int DP[MAXN], n;

int compute (int left) {
    if (DP[left] != 0) {
        return DP[left];
    }
    for (int i = 1; i <= 6; i++) {
        if (left - i >= 0) {
            DP[left] += compute(left - i);
            DP[left] %= MOD;
        }
    }
    return DP[left];
}

int main() {
    cin >> n;
    memset(DP, 0, sizeof(DP));
    DP[0] = 1;
    cout << compute(n) << endl;
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: iostream c++ 
Cpp :: c++ vector 
Cpp :: c++ data types 
Cpp :: c++ inheritance constructor 
Cpp :: online ide c++ 
Cpp :: how to sort array in c++ 
Cpp :: linux c++ sigint handler 
Cpp :: prevent getting data from data-tooltip-content tippyjs 
Cpp :: c++ std string to float 
Cpp :: loop c++ 
Cpp :: how to access a vector member by its index 
Cpp :: resharper fold statement 
Cpp :: c++ delay 
Cpp :: copy constructor c++ syntax 
Cpp :: how to fill vector from inputs c++ 
Cpp :: c++ garbage collection 
Cpp :: read a whole line from the input 
Cpp :: closing a ifstream file c++ 
Cpp :: statements 
Cpp :: Start mongodb community server 
Cpp :: web dev c++ 
Cpp :: dangling pointer in cpp 
Cpp :: c language all keywords in string 
Cpp :: unique element in array in c 
Cpp :: file streams in c++ 
Cpp :: substring function in c++ 
Cpp :: array bubble sort c++ static 
Cpp :: wgat is duble in c++ 
Cpp :: how to increase the length of a string 
Cpp :: find n unique integers sum up to zero 
ADD CONTENT
Topic
Content
Source link
Name
7+4 =