AC,没啥难度,暴力
class Solution {
public int[] distributeCandies(int candies, int num_people) {
int k = 1;
int[] ans = new int[num_people];
for(int i = 0; candies > 0; i++){
if(candies > k){
ans[i% num_people] = ans[i% num_people] + k;
candies = candies - k;
k++;
}
else{
ans[i% num_people] = ans[i% num_people] + candies;
candies = 0;
}
}
return ans;
}
}