借鉴了讨论里面的写法,然后按照核心代码的形式写出完整代码并进行了注释 #include<iostream> #include<vector> using namespace std; class Solution{ public: int divideapple(int& n, vector<int>& s){ /* 思路:1.先遍历数组,统计每个奶牛手中的苹果; 2.求平均数m,若可以整除,表示有分配方案,否则没有; 3.遍历每个元素,比较当前元素与m的差值,如果差值不是2的倍数,说明...