当前位置:网站首页>Leetcode 2028. find out the missing observation data
Leetcode 2028. find out the missing observation data
2022-07-22 18:49:00 【Great white sheep_ Aries】
Title Description
2028. Find missing observations
solution :
class Solution {
public:
vector<int> missingRolls(vector<int>& rolls, int mean, int n) {
vector<int> ans;
int m = rolls.size();
int t = mean * (m + n);
for (auto i : rolls) t -= i;
if (t < n || t > 6 * n) return ans;
for (int i = 0; i < n; i++) ans.emplace_back(t / n);
if (t / n * n < t)
{
int d = t - (t / n * n);
for (int i = 0; d > 0; i++, d--) ans[i]++;
}
return ans;
}
};
边栏推荐
- 位与:一个数&1的结果
- 递归求简单交错幂级数的部分和 (15分)
- [SDIO] sd2.0 protocol analysis summary (II) -- SD card identification & data transmission process
- 数据库出现乱码,求解决办法、思路?
- LeetCode: 627. 变更性别
- 项目启动过后,一直循环加载mapper xml文件
- Unity:素材下载
- [STM32] STM32 SDIO SD card read / write test (III) -- SD_ Init card stage of init
- MySQL的语句执行顺序
- [SDIO] SDIO, SD card, FatFs file system related article index
猜你喜欢
PTA 6-11 求自定类型元素序列的中位数 (25 分)
bjyx
Summary 20220121
06. Liskov Substitution Principle (LSP)
【Nordic】nRF52810 OTA升级(二)–DFU如何使用
[STM32] STM32 SDIO SD card read / write test (II) -- SD_ Power on phase of init
Over the weekend, I had a dinner with the technology gurus and talked about the "golden nine and silver ten" peak of the software testing industry [the trend of involution has been formed]
[SDIO] sd2.0 protocol analysis summary (II) -- SD card identification & data transmission process
05. Law of Demeter LOD
LeetCode 304. 二维区域和检索 - 矩阵不可变
随机推荐
PAT乙级1019 数字黑洞 (20 分) (测点错误可能原因)
NRF24L01 wireless module setting transmit receive mode method
【Nordic】nRF52810 OTA升级(三)–DFU理论分析
【QT源代码复用】QDateTimeEdit的下拉按钮事件响应
OSI model, tcp/ip model
07.合成复用原则(Composite/Aggregate Reuse Principle,CARP)
JSON序列化对象时,如何返回有空值的带属性名称json字符串?
解决不能维持IntelliJ 之 Target bytecode Version版本号
[Nordic] nrf52810 OTA upgrade (II) – how to use DFU
ECSHOP prompts "the template file themesmobile/mo_paleng_mobile/index.dwt cannot be modified"?
(c语言)数组是一种特殊的指针?
Recursively find the partial sum of simple alternating power series (15 points)
LeetCode 304. 二维区域和检索 - 矩阵不可变
Summary 20220211
04.接口隔离原则(Interface Segregation Principle)
amh多mysql版本共存?
1.QTableWidget插入按钮,灵活删除本行,一列显示行号
ECSHOP configures wechat payment, and the wechat developer tool prompts "unbound web developer" when wechat payment pops up
总结20220209
总结20220215(kruskal和prim)