2001-2010¶
2011-2020¶
2021-2030¶
2028. 找出缺失的观测数据¶
class Solution {
public:
vector<int> missingRolls(vector<int> &rolls, int mean, int n) {
int m = rolls.size(), cnt = m + n, sum = cnt * mean;
for (auto item: rolls) sum -= item;
vector<int> ans;
if (sum > n * 6 || sum < n) {
return ans;
} else {
int rem = sum % n, idx = 0;
ans.resize(n, sum / n);
while (rem--) ++ans[idx++];
return ans;
}
}
};