题目链接:https://leetcode-cn.com/problems/nge-tou-zi-de-dian-shu-lcof/
class Solution {
public:
vector<double> twoSum(int n) {
vector<vector<int>> f(n + 1, vector<int>(6 * n + 1, 0));
f[0][0] = 1;
for(int i = 1; i <= n; i++)
for(int j = 1; j <= 6 * i; j++)
for(int cur = 1; cur <= 6; cur++)
if(j - cur >= 0)
f[i][j] += f[i - 1][j - cur];
double total = 0;
for(int i = n; i <= 6 * n; i++)
total += f[n][i];
vector<double> res(6 * n + 1);
for(int i = n; i <= 6 * n; i++)
res[i] = f[n][i] / total;
return vector<double> (res.begin() + n, res.end());
}
};
原文:https://www.cnblogs.com/Trevo/p/13029191.html