problem

1103. Distribute Candies to People

solution:没看明白代码。。。

  1. class Solution {
  2. public:
  3. vector<int> distributeCandies(int candies, int num_people) {
  4. vector<int> res(num_people);
  5. for(int i=; candies>; candies-=++i)
  6. res[i%num_people] += min(i+, candies);
  7. return res;
  8. }
  9. };

参考

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. 并发编程:Thread和Runable-01

      1.继承Thread类(不推荐) 代码很简单,就不说了 public class ThreadTest02 { public static void main(String[] args) { n ...

  2. Mybatis获取自增主键值

    1.配置文件变化 <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE mapper PUBLI ...

  3. git的优点跟缺点?

    优点: 1.分布式开发时,可以git clone克隆一个本地版本,然后在本地进行操作提交,本地可以完成一个完整的版本控制.在发布的时 候,使用git push来推送到远程即可. 2.git分支的本质是 ...

  4. Appium自动化测试教程-自学网-monkey自定义脚本实践

    自定义脚本的稳定性测试 常规Monkey测试执行的是随机的事件流,但如果只是想让Monkey测试某个特定场景这时候就需要用到自定义脚本了,Monkey支持执行用户自定义脚本的测试,用户只需要按照Mon ...

  5. 最短路--SPFA及其优化

    SPFA Shortest Path Faster Algorithm 最短路径最快算法 算法思想 SPFA 算法是 Bellman-Ford算法 的队列优化算法的别称,通常用于求含负权边的单源最短路 ...

  6. MD5加密的引用

    使用MD5 加密时 需要在后台代码中添加using System.Security.Cryptography; 引用 //MD5加密密码 byte[] a = MD5.Create().Compute ...

  7. leetcode解题报告(19):Contains Duplicate II

    描述 Given an array of integers and an integer k, find out whether there are two distinct indices i an ...

  8. TensorFlow(十四):谷歌图像识别网络inception-v3下载与查看结构

    上代码: import tensorflow as tf import os import tarfile import requests #inception模型下载地址 inception_pre ...

  9. Linux下RabbitMQ的集群

    一.RabbitMQ安装 1.1.下载Erlang的rpm包 RabbitMQ是Erlang语言编写,所以Erang环境必须要有,注:Erlang环境一定要与RabbitMQ版本匹配:https:// ...

  10. Mybatis 向statement传入多个参数

    1.一般情况下可以将多个参数放入Map,让Map作为statement的参数 public void update(@Param("fieldMap") Map<String ...