[C++] DP solution
Meaning of dp parameters: dp[times][last appeared number][last appear number consecutive times]\nFor the first time: \ndp[0][0 to 5][1]=1\n\nFor the ith time: \
Meaning of dp parameters: dp[times][last appeared number][last appear number consecutive times]\nFor the first time: \n**dp[0][0 to 5][1]=1**\n\nFor the ith time: \n**dp[i][j={0 to 5}][1] = sum(dp[i - 1][k={0 to 5, except j}][m={1 to rollMax[k]}])**\nSince if j is the last appeared number, and also no j appeared before this j, this case equals the sum of all cases of (0 to 5, except j) in previous step.\n**dp[i][j={0 to 5}][m={2 to rollMax[j]}] = dp[i - 1][j][m - 1]**\nSince if there are consective j, this case equals [i - 1][j][m - 1].\n\nAnd the **result=sum(dp[n- 1][k={0 to 5, except j}][m={1 to rollMax[k]}])**\n```c++\nclass Solution {\npublic:\n    int dieSimulator(int n, vector<int>& rollMax) {\n        int mod = 1e9 + 7;\n        vector<vector<vector<int>>> dp(n, vector<vector<int>>(6, vector<int>(16, 0)));\n        for(int i = 0; i < 6; ++i) {\n            dp[0][i][1] = 1;\n        }\n        for(int i = 1; i < n; ++i) {\n            for(int j = 0; j < 6; ++j) {\n                // calculate dp[i][j][1] = sum(dp[i - 1][except j][1 to rollMax[j]])\n                for(int k = 0; k < 6; ++k) {\n                    if(k == j) { continue; }\n                    for(int m = 1; m <= rollMax[k]; ++m) {\n                        dp[i][j][1] = (dp[i][j][1] + dp[i - 1][k][m]) % mod;\n                    }\n                }\n                \n                // calculate dp[i][j][2] to dp[i][j][rollMax[j]]\n                for(int m = 2; m <= rollMax[j]; ++m) {\n                    dp[i][j][m] = dp[i - 1][j][m - 1];\n                }\n            }\n        }\n        \n        int answer = 0;\n        for(int i = 0; i < 6; ++i) {\n            for(int j = 1; j <= rollMax[i]; ++j) {\n                answer = (answer + dp[n - 1][i][j]) % mod;\n            }\n        }\n        return answer;\n    }\n};\n```
[]