【Leetcode_easy】1103. Distribute Candies to People
problem
1103. Distribute Candies to People
solution:没看明白代码。。。
class Solution {
public:
vector<int> distributeCandies(int candies, int num_people) {
vector<int> res(num_people);
for(int i=; candies>; candies-=++i)
res[i%num_people] += min(i+, candies);
return res;
}
};
参考
1. Leetcode_easy_1103. Distribute Candies to People;
2. Discuss;
完
【Leetcode_easy】1103. Distribute Candies to People的更多相关文章
- 【leetcode】1103. Distribute Candies to People
题目如下: We distribute some number of candies, to a row of n = num_people people in the following way: ...
- 【leetcode】575. Distribute Candies
原题 Given an integer array with even length, where different numbers in this array represent differen ...
- 【LeetCode】575. Distribute Candies 解题报告(Java & Python)
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 Java解法 Python解法 日期 题目地址:ht ...
- LeetCode 1103. Distribute Candies to People
1103. Distribute Candies to People(分糖果||) 链接:https://leetcode-cn.com/problems/distribute-candies-to- ...
- 【BZOJ】1103: [POI2007]大都市meg
http://www.lydsy.com/JudgeOnline/problem.php?id=1103 题意:一棵n节点的树(1<=n<=250000),m条边(1<=m<= ...
- LeetCode 1103. Distribute Candies to People (分糖果 II)
题目标签:Math 题目让我们分发糖果,分的糖果从1 开始依次增加,直到分完. for loop可以计数糖果的数量,直到糖果发完.但是还是要遍历array 给people 发糖,这里要用到 index ...
- [LeetCode] 1103. Distribute Candies to People 分糖果
题目: 思路: 本题一开始的思路就是按照流程一步步分下去,算是暴力方法,在官方题解中有利用等差数列进行计算的 这里只记录一下自己的暴力解题方式 只考虑每次分配的糖果数,分配的糖果数为1,2,3,4,5 ...
- 【PAT】1103 Integer Factorization(30 分)
The K−P factorization of a positive integer N is to write N as the sum of the P-th power of K positi ...
- 【Leetcode_easy】1021. Remove Outermost Parentheses
problem 1021. Remove Outermost Parentheses 参考 1. Leetcode_easy_1021. Remove Outermost Parentheses; 完
随机推荐
- 用CSS 实现 浮动元素的 水平居中
问题描述: 基本的html结构: <div> <!-- <span>1</span> <span>2</span> <span& ...
- vue 单向数据流
- chrome 調試 node 代碼
(1)node --inspect-brk debug/demo (2)通过 chrome 进行调试 (3) chrome://inspect 进入chrome调试界面 --inspect ...
- Airtest真机链接(一)
确认ADB是否能够正常连接到手机 windows系统下: 用USB线连好手机后,进入AirtestIDE文件夹,在 AirtestIDE_2019-05-09_py3_win64/airtest/co ...
- 学习了武沛齐讲的Day10-完
int 整形 int 将字符串转换为数字 x.bit_length() ===== 当前数字的二进制,至少用n位表示 str 字符串 x.capitalize()== ...
- HTML div块内剧中
在HTML中有一个块内元素剧中的方法 那就是margin:0 auto; 剧中前 剧中后
- 数据库学习之五--Union, Union All和Intersect
一.定义 Union操作符用于合并两个或多个SELECT语句的结果集: 注:1. Union连接的Select语句之间必须拥有相同数量的列: 2. 列也必须拥有相似的数据类型: 3. 每条 SELEC ...
- 通过Confulence API统计用户文档贡献量
Confulence提供了非常清晰的RESTful API,直接使用API比confluence_python_cli这个库更方便. 参考文档:https://developer.atlassian. ...
- python常用函数1
map()函数 map()是python 内置 的高届函数 ,接收一个函数 f 和一个list,并通过把函数 f 依次作用在list的每个元素上,得到一个新的 list 并返回. 比如,对于l ...
- Thift初探 (一)
Maven pox.xml: <dependency> <groupId>org.apache.thrift</groupId> <artifactId> ...