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的更多相关文章

  1. 【leetcode】1103. Distribute Candies to People

    题目如下: We distribute some number of candies, to a row of n = num_people people in the following way: ...

  2. 【leetcode】575. Distribute Candies

    原题 Given an integer array with even length, where different numbers in this array represent differen ...

  3. 【LeetCode】575. Distribute Candies 解题报告(Java & Python)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 Java解法 Python解法 日期 题目地址:ht ...

  4. LeetCode 1103. Distribute Candies to People

    1103. Distribute Candies to People(分糖果||) 链接:https://leetcode-cn.com/problems/distribute-candies-to- ...

  5. 【BZOJ】1103: [POI2007]大都市meg

    http://www.lydsy.com/JudgeOnline/problem.php?id=1103 题意:一棵n节点的树(1<=n<=250000),m条边(1<=m<= ...

  6. LeetCode 1103. Distribute Candies to People (分糖果 II)

    题目标签:Math 题目让我们分发糖果,分的糖果从1 开始依次增加,直到分完. for loop可以计数糖果的数量,直到糖果发完.但是还是要遍历array 给people 发糖,这里要用到 index ...

  7. [LeetCode] 1103. Distribute Candies to People 分糖果

    题目: 思路: 本题一开始的思路就是按照流程一步步分下去,算是暴力方法,在官方题解中有利用等差数列进行计算的 这里只记录一下自己的暴力解题方式 只考虑每次分配的糖果数,分配的糖果数为1,2,3,4,5 ...

  8. 【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 ...

  9. 【Leetcode_easy】1021. Remove Outermost Parentheses

    problem 1021. Remove Outermost Parentheses 参考 1. Leetcode_easy_1021. Remove Outermost Parentheses; 完

随机推荐

  1. 金蝶二次开发C#

    1 建立C#类库项目 2 引用EBOS组建Kingdee.K3.BOS.PlugInModel 3 示例代码 usingSystem; usingSystem.Collections.Generic; ...

  2. html中的table导出Excel (亲测有用(●'◡'●))

    演示地址: http://www.jq22.com/yanshi3312 具体代码: <!DOCTYPE html> <html lang="zh-CN"> ...

  3. 03_Elastic部署

    ES集群部署 elastic不能用root用户去启动,否则会报错,所以创建elastic用户 1.创建elastic用户 $ useradd elastic -s /sbin/nologin 2..部 ...

  4. js 读xml文件

    参考 http://www.w3school.com.cn/xmldom/dom_document.asp A.xml <?xml version="1.0" encodin ...

  5. CSPS分数取mod赛92-93

    我好菜啊..... 92只会打暴力,93暴力都不会了 模拟92, T1:直接ex_gcd加分类讨论即可 T2:考场只会打暴搜,正解为排序后线段树解决,排序的关键字为a+b,因为如果ai<bj&a ...

  6. mysql my.cnf文件

    一.mysqld组值设置: 1.user = mysql #启动mysql的用户.2.pid-file = /var/run/mysqld/mysqld.pid #指定pid文件.3.socket = ...

  7. MangoDB在C#中的使用

    http://blog.sina.com.cn/s/blog_927f3c2401011937.html 图形工具 http://api.mongodb.org/csharp/current/html ...

  8. coercing to Unicode: need string or buffer, geoprocessing value object found

    workbook.save(outxls),保存xls,出现上面的错误原因是:outxls不是错误 arcpy.AddMessage("--------"+outxls) cann ...

  9. [ERR] 2006 - MySQL server has gone away如何解决

    解决方案: max_allowed_packet = 16M 改大点! 文章来源:外星人来地球 欢迎关注,有问题一起学习欢迎留言.评论

  10. CRF 初步了解

    国外有一个很著名的条件随机场的教程,是英文的,原文: http://blog.echen.me/2012/01/03/introduction-to-conditional-random-fields ...