s*t
2 楼
老是看电脑眼睛很干,请问最近滴眼液有deal吗?
还有戴隐形眼镜眼镜干用的滴眼液或者是tear的那种比较好用呢?
还有戴隐形眼镜眼镜干用的滴眼液或者是tear的那种比较好用呢?
z*3
3 楼
这题有最优解么?
f*w
4 楼
RA下个月的blink
s*t
6 楼
请教一下具体应该怎么买呢?不会啊~
b*7
9 楼
完全背包问题
f(i,v) = min{f(i-1,v), f(i-1,v - k[i])+1}
f(i,v) 用f(v)表示
初始f(v) = MAX_INT (v = 1,..., sum), f(0) = 0
for i = 0 ... m-1
for v = 1...sum
if v >= k[i] and f(v-k[i]) + 1 < f(v)
f(v) = f(v-k[i]) + 1
return f(sum)
参见:三种背包问题http://www.wutianqi.com/?p=539
f(i,v) = min{f(i-1,v), f(i-1,v - k[i])+1}
f(i,v) 用f(v)表示
初始f(v) = MAX_INT (v = 1,..., sum), f(0) = 0
for i = 0 ... m-1
for v = 1...sum
if v >= k[i] and f(v-k[i]) + 1 < f(v)
f(v) = f(v-k[i]) + 1
return f(sum)
参见:三种背包问题http://www.wutianqi.com/?p=539
j*7
11 楼
public static int minCoinsFor(int[] denom, int total) {
int[][] choice = new int[denom.length + 1][total + 1];
int[][] DP = new int[denom.length + 1][total + 1];
DP[denom.length][0] = 0;
for (int i = 1; i <= total; i++) {
DP[denom.length][i] = -1;
}
for (int i = denom.length - 1; i >= 0; i--) {
for (int j = 0; j <= total; j++) {
int min = -1;
for (int k = 0; k * denom[i] <= j; k++) {
int temp = DP[i + 1][j - k * denom[i]];
if (temp != -1) {
temp = temp + k;
if (min == -1) {
choice[i][j] = k;
min = temp;
} else if (temp < min) {
min = temp;
choice[i][j] = k;
}
}
}
DP[i][j] = min;
}
}
int min = DP[0][total];
if (min != -1) {
for (int i = 0; i < denom.length; i++) {
if (choice[i][total] != 0) {
System.out.print(choice[i][total] + ":" + denom[i] + "s
");
total = total - choice[i][total] * denom[i];
}
}
System.out.println();
}
return min;
}
int[][] choice = new int[denom.length + 1][total + 1];
int[][] DP = new int[denom.length + 1][total + 1];
DP[denom.length][0] = 0;
for (int i = 1; i <= total; i++) {
DP[denom.length][i] = -1;
}
for (int i = denom.length - 1; i >= 0; i--) {
for (int j = 0; j <= total; j++) {
int min = -1;
for (int k = 0; k * denom[i] <= j; k++) {
int temp = DP[i + 1][j - k * denom[i]];
if (temp != -1) {
temp = temp + k;
if (min == -1) {
choice[i][j] = k;
min = temp;
} else if (temp < min) {
min = temp;
choice[i][j] = k;
}
}
}
DP[i][j] = min;
}
}
int min = DP[0][total];
if (min != -1) {
for (int i = 0; i < denom.length; i++) {
if (choice[i][total] != 0) {
System.out.print(choice[i][total] + ":" + denom[i] + "s
");
total = total - choice[i][total] * denom[i];
}
}
System.out.println();
}
return min;
}
r*h
12 楼
不需要ls这么复杂啊,1D的经典多重背包问题
a = [1, 3, 5, 7, 9]
num = [9999 for i in range(30)]
num[0] = 0
for coin in a:
i = coin
while i<30:
if num[i-coin]+1 < num[i]:
num[i] = num[i-coin]+1
i = i+1
print(num)
a = [1, 3, 5, 7, 9]
num = [9999 for i in range(30)]
num[0] = 0
for coin in a:
i = coin
while i<30:
if num[i-coin]+1 < num[i]:
num[i] = num[i-coin]+1
i = i+1
print(num)
相关阅读
求解惑pf请问买奶粉出的带有target字样的MFC可以在CVS用吗?mini的10 off胖,一张卡可以用几次?谢谢关于staple用rewards买rewards的问题请教 staples's free SW转让 2张NM costco 支票,面值$3 & $7staples 这周的打印制可以用20%胖子吗CVS 的老小二在搞什么呢,求解买关节药,可能RA比较便宜.Duracell Rebate黑巧克力上哪买便宜呢?问一下,刚才我发的Living Social的帖子为啥被删了?什么coupon都没准备,没想到cvs还小赚的一单求推荐一价廉物美的的portable projector。。。关于mini胖(胖子在4楼)收到cvs online 30%off,除了买奶粉,还有什么可以买的?怎样才能让一楼的的中文电视连上二楼的网络哪?10off50胖子还出吗?eGifter又有10off50 eGC promotionBB霜是护肤品吗?