
Python
zn_3065
这个作者很懒,什么都没留下…
展开
-
将字符按照原有几个字符串的排列规律组和成一个新的字符串
这个问题是在https://py.checkio.org/上面的一道题原题我放在下面.The Robots have found an encrypted message. We cannot decrypt it at the moment, but we can take the first steps towards doing so. You have a set of "words", all in lower case, and each word contains symbols in原创 2020-07-08 14:19:40 · 485 阅读 · 0 评论 -
背包问题, Python解法
#背包问题# i 物品序号(总共多少物体) w物品体积 v物品价值 g背包容量 V总价值# 对于第i个物品,有拿和不拿两种行为,取价值最高的。# max{V(i-1,g), V(i-1,g-w)+vi}# V(i-1,g)不拿当前物体,总价值就是拿上一个物体的价值。# V(i-1,g-wi)+vi拿当前物体,总价值就是拿上一个物体的价值加上当前i的价值。g-w的意思是背包要给当前物体留下足够的空间。import numpyFIND=[]def bag (i:int, w:list, v.原创 2020-07-01 16:56:08 · 350 阅读 · 0 评论