现有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])

  

posted @ 2016-09-01 13:54  hjr_rong  阅读(295)  评论(0编辑  收藏  举报