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. 用Python写网络爬虫 第二版

    书籍介绍 书名:用 Python 写网络爬虫(第2版) 内容简介:本书包括网络爬虫的定义以及如何爬取网站,如何使用几种库从网页中抽取数据,如何通过缓存结果避免重复下载的问题,如何通过并行下载来加速数据 ...

  2. java 数组对象的应用

    public class Student 2 { 3 // 成员变量 4 private String name; 5 private int age; 6 7 // 构造方法 8 public St ...

  3. 002_软件安装之_keil4与keil5共存

    目的:实现keil4和keil5的共存 1. Keil4 主要用来开发 C51 程序 2. Keil5 也就是 MDK 主要用来开发 ARM 芯片,如 STM32 系列芯片 3. 资料下载地址:链接: ...

  4. jquery验证时间

    http://blog.csdn.net/guguojin/article/details/7045908 验证时间的正则表达式集合 //日期格式yyyy  PatternsDict.date_y= ...

  5. [English] - 单词阶段1

    百词斩这个app很好玩,尤其是在记忆单词的时候,效果显著. 有的PK赛场也是比较谁的单词翻译提交的快,这个我曾经连胜好几次.

  6. luogu P3567 [POI2014]KUR-Couriers

    二次联通门 : luogu P3567 [POI2014]KUR-Couriers MMP 指针 RE + MLE + WA..... 不得已...向黑恶的数组实力低头 /* 指针 */ #inclu ...

  7. Java学习日记基础篇(六)—— 抽象类、接口、final

    抽象类 为什么要有抽象类? 因为父类方法有不确定性,我们在Animal中定义了一个方法,但是它会被子类的方法覆盖掉,我们就不知道这个方法原本是做什么的 public class test1 { pub ...

  8. 第六章、Linux 的档案权限不目彔配置

    1. 使用者不群组 2. Linux 档案权限概念 2.1 Linux 文件属怅 2.2 如何改变文件属怅不权限: chgrp, chown, chmod 2.3 目彔不档案乀权限意丿 2.4 Lin ...

  9. JAVA基础知识|java虚拟机(JVM)

    一.JVM简介 java语言是跨平台的,兼容各种操作系统.实现跨平台的基石就是虚拟机(JVM),虚拟机不是跨平台的,所以不同的操作系统需要安装不同的jdk版本(jre=jvm+类库:jdk=jre+开 ...

  10. Qt实现原生Flow实现不了的Item错误排列效果,类似淘宝商品展示

    main.qml import QtQuick 2.12 import QtQuick.Window 2.12 import QtQml.Models 2.12 Window { visible: t ...