现有21朵鲜花分给5人,若每个人分的鲜花数各不相同,则分的鲜花最多的人至少分的多少朵鲜花?



     var all = 21; var people = [0,0,0,0,0]; for(var i=1;i<=people.length;i++){ people[i-1] = i; all -= i; } var start = people.length-1; while(all>0){ people[start]++; all--; start--; if (start<=0) {start = people.length-1}; } alert(people[people.length-1])

  

原文地址:https://www.cnblogs.com/hejianrong/p/5829560.html