码迷,mamicode.com
首页 > 其他好文 > 详细

divide an integer into X parts (as even as possible)

时间:2014-08-26 05:20:04      阅读:205      评论:0      收藏:0      [点我收藏+]

标签:style   blog   color   os   io   for   ar   art   div   

the algorithm is like this: it evenly spreads an integer N over K cells.

for i = 0 to K
    array[i] = N / K    # integer division

# divide up the remainder
for i = 0 to N mod K
    array[i] += 1

 

divide an integer into X parts (as even as possible)

标签:style   blog   color   os   io   for   ar   art   div   

原文地址:http://www.cnblogs.com/miaoz/p/3936329.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!