Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
20L(有缩行之嫌)纯二进制滚动DP(428K 16MS可惜打表之下神马都是浮云)8461762 kill_myself 2411 Accepted 428K 16MS G++ 584B 2011-04-09 23:42:09 #include<cstdio> #include<string.h> long long f[2][4100],a,b,n,m,k,j,p; int main(){ while(scanf("%d%d",&n,&m),memset(f,0,sizeof(f)),f[0][0]=p=1,a=n>m?n:m,b=n+m-a){ while(a--) for(j=0;++j<=b;memset(f[p=1-p],0,sizeof(f[p]))) for(k=(1<<b);--k+1;) if(k&1<<j-1) f[p][k&~(1<<j-1)]+=f[1-p][k]; else{ f[p][k|1<<j-1]+=f[1-p][k]; if(j<b&&!(k&1<<j)) f[p][k|1<<j]+=f[1-p][k]; } printf("%lld\n",f[1-p][0]); } } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator