1103.Distribute Candies to People

`示例 1：​输入：candies = 7, num_people = 4输出：[1,2,3,1]解释：第一次，ans[0] += 1，数组变为 [1,0,0,0]。第二次，ans[1] += 2，数组变为 [1,2,0,0]。第三次，ans[2] += 3，数组变为 [1,2,3,0]。第四次，ans[3] += 1（因为此时只剩下 1 颗糖果），最终数组变为 [1,2,3,1]。示例 2：​输入：candies = 10, num_people = 3输出：[5,2,3]解释：第一次，ans[0] += 1，数组变为 [1,0,0]。第二次，ans[1] += 2，数组变为 [1,2,0]。第三次，ans[2] += 3，数组变为 [1,2,3]。第四次，ans[0] += 4，最终数组变为 [5,2,3]。​​提示：​1 <= candies <= 10^91 <= num_people <= 1000`

`class Solution {public:    vector<int> distributeCandies(int candies, int num_people) {        double a=num_people*num_people/2.0;        double b=num_people/2.0;        int count=(sqrt(b*b+4*a*candies) -b)/(2.0*a);        vector<int >res(num_people);        int sum=(count-1)*count/2*num_people*num_people +count*(num_people+1)*num_people/2;            for(size_t i=0; i<num_people;i++)            res[i]+=num_people*(count-1)*count/2 + count*(i+1);        int r=candies-sum;        for(size_t i=0;i<num_people;i++)        {         int tmp=count*num_people+i+1;            if(tmp<r)            {res[i]+=tmp;             r-=tmp;        }            else            {res[i]+=r;            break;}        }​​        cout<<"a: "<< a << "b: " << b<< "count: "<<count<<"sum: "<<sum<<endl;        return res;    }};`