题目:
6种球, 价值分别为1..6, 给出每种的数量, 问能不能分成价值相同的两堆
思路:
1. 将它当成背包问题来看, 包的容积一定(这里的”体积”就是球的价值, 包的容积V=球总价值的一半), 问能不能分成相等两堆即, 包是不是能装满.
2. 这里不用球背包问题中的极值, 不存在价值的概念, 所以v数组用bool型就可以.
3. 因为每种球数量有限制所以不是典型的完全背包问题(目前就看了两个..01背包和完全背包), 我对v中的每一个true它后面每i个赋值成为true, 直到这层的球耗尽. 比如开始v[0]=true v[1..V]=false, 1球的数量为10, 则第一层i循环后, v[0..10]=true v[11.V]=false
4. 3中直接赋值会对后面的计算有影响, 我很蹩脚的另外建了个列表作临时用…
5. 一次AC, 但是时间效率很低, 7XXms..都快超了(大家都爱说..都快超了), 感觉应该是算法过于繁琐..还倒来倒去的, 有空得试试O(log V/c[i])那算法
6. <背包九讲>下载 http://axlarts.com/uploads/documents/pack9lessons.doc 没作者 没写版权声明 直接转了..
代码:
[cpp] #include <cstdio>
#include <cstring>
int main() {
int n[7],N,V;
bool v[60001],t[60001];
N=0;
while(++N) {
V=0;
bool isEnd=true;
for(int i=1;i<=6;i++) {
scanf("%d",n+i);
V+=n[i]*i;
if(n[i])
isEnd=false;
}
if(isEnd)
break;
printf("Collection #%d:\n",N);
if(V%2) {
printf("Can’t be divided.\n\n");
continue;
}
///initialize
V/=2;
v[0]=true;
memset(v+1,false,V);
for(int i=1;i<=6;i++) {
memset(t,false,V+1);
for(int j=0;j<=V;j++) {
if(!v[j])
continue;
for(int k=0;k<=n[i]*i;k+=i) {
if((j+k)>V)
break;
t[j+k]=true;
}
}
for(int j=1;j<=V;j++)
v[j]=t[j];
}
if(v[V])
printf("Can be divided.\n\n");
else
printf("Can’t be divided.\n\n");
}
return 0;
}[/cpp]
References:
Hitnspin login http://www.privatecams.com
References:
Hit’n’spin casino 50 free spins kak2z.ru
References:
Hitnspin casino freispiele jnews.xsrv.jp
References:
Hitnspin casino kostenlos spielen semanticweb.cs.vu.nl
References:
Hitnspin casino ohne anmeldung yandex.ee
References:
Hitnspin casino review http://xtblogging.yn.lt/
References:
Hitnspin kundensupport cruises.ruscruiz.ru
References:
Hitnspin casino einzahlung https://trac.filezilla-project.org/search?q=https://jagoan-hosting.online/juliannelyell6
References:
Hitnspin casino mit echtgeld wiki.kubg.edu.ua
References:
Lollybet Casino 10 Euro Bonus http://clients1.google.sh
References:
Lollybet Casino Bonus ohne Einzahlung http://clients1.google.co.cr
References:
Lollybet Meinung https://php.ru/forum/proxy.php?link=https://demo.indeksyazilim.com/katiabogart122
References:
Lollybet No Deposit Bonus http://www.google.com.na
References:
Lollybet Casino Paysafecard https://vocerh.abril.com.br
References:
Lollybet Casino VIP http://cse.google.dz/url?sa=i&url=https://rentry.co/z3azvt6n
References:
Hit n spin casino erfahrungen http://cse.google.cm/
References:
Hit’n’spin casino 25 euro code http://cse.google.cat/url?sa=i&url=https://gardenwiki.site/wiki/HitnSpin_Casino_Test_Objektive_Casino_Bewertung_Erfahrungen
References:
Hitnspin casino echtgeld http://cse.google.am/url?sa=i&url=https://www.altamira.edu.ec/profile/pruittwkhstensgaard28790/profile
References:
Hit and spin casino http://images.google.com.cy
References:
Hitnspin casino auszahlung erfahrungen http://community.robo3d.com
References:
Hit n spin casino 25 euro code http://cies.xrea.jp/jump/?https://qiita.com/sandeffect85
References:
Hit’n’spin casino 25 euro bonus ohne einzahlung
100not.ru
References:
Hit’n’spin casino no deposit bonus http://images.google.com.vn/url?sa=t&url=https://headlinelog.space/item/hitnspin-promo-code-2025-top-aktionscode-hier-einl-sen
References:
Online pokies real money payid https://devnew.judefly.com
References:
Payid pokies instant withdrawal findjobs.my
References:
Online pokies australia payid real money https://www.loginscotia.com/sofiabrunning7
References:
Online pokies australia payid real money https://career.braincode.com.bd/employer/best-online-casino-australia-payid-pokies-2026-rankings/
References:
Best instant payid pokies australia real money https://channel-u.tv/@arron01l90371?page=about
References:
Pokies net australia payid withdrawal https://bdemployee.com/
References:
Payid online pokies https://www.sundayrobot.com/tedmcquiston1
References:
Online pokies australia payid real money kfz-eske.de
References:
Lollybet Casino Erfahrungen cse.google.co.in
References:
Lollybet Casino VIP https://skfo900815.cafe24.com/member/login.html?refdoc=member/login.html&noMemberOrder=&returnUrl=https://cannadirect.com/billymallard44
References:
Lollybet Casino Aktion https://www.sandlotminecraft.com/proxy.php?link=https://getshort.in/lkiearnest1251
References:
Lollybet Slots https://cutrun.ru/
References:
Lollybet Casino Willkommensbonus http://www.earticle.net/
References:
Lollybet Casino Live Casino https://lepidopterolog.ru
References:
Lollybet Support http://images.google.com.ai/url?q=https://qr.dsd.edu.gh/jennasunderlan
References:
Lollybet Casino Paysafecard nop.vifa.dk
References:
Lollybet APK http://forum.vhfdx.ru/
References:
Lollybet Casino Bonus 38.Staikudrik.com
References:
Lollybet Casino 10 Euro Bonus https://clients1.google.cat
References:
Cancun casino hirings.online
References:
Craps for dummies trabajaensanjuan.com
References:
Terribles casino academy.tatiosa.com
References:
London casino https://a2znaukri.com/employer/bonus-3000-300-fs/
References:
Lollybet Casino Test https://httpx.lapbook.ru
References:
Lollybet Aktionscode http://www.google.mv/url?q=https://eram-jobs.com/employer/lollybet-casino-test-2026-ist-es-seri%C3%B6s?
References:
Lollybet Casino DE https://toyota-verso.ru:443/ucp.php?mode=logout&redirect=https://sportjobs.gr/employer/lolly-bet/