problem
solution:没看明白代码。。。
class Solution {public: vector distributeCandies(int candies, int num_people) { vector res(num_people); for(int i=0; candies>0; candies-=++i) res[i%num_people] += min(i+1, candies); return res; }};
参考
1. ;
2. ;
完
本文共 371 字,大约阅读时间需要 1 分钟。
problem
solution:没看明白代码。。。
class Solution {public: vector distributeCandies(int candies, int num_people) { vector res(num_people); for(int i=0; candies>0; candies-=++i) res[i%num_people] += min(i+1, candies); return res; }};
参考
1. ;
2. ;
完
转载于:https://www.cnblogs.com/happyamyhope/p/11157207.html