设v=[10:1,15:2,20:3];(i=[0,1,2]列表中值的索引)
n = 10 - (i + 1) = 10 - (0 + 1) = 9 ==> newV = [0, 0, 0, 0, 0, 0, 0, 0, 0, 1]
n = 15 - (9 + i + 1) = 15 - (9 + 1 + 1) = 4 ==> newV =[0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 2]
n = 20 - ( 9 + 4 + 2 + 1 ) = 20 - 16 = 4 ==> newV =[0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 2, 0, 0, 0, 0, 3]
finalV = [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 2, 0, 0, 0, 0, 3]`
谢谢你的铅笔和纸。在
你的问题有些不清楚的地方,但这里有一个可能的解决办法
相关问题 更多 >
编程相关推荐