Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Re:再来一个25行的插头DP的AC代码,具体就不解释了XD

Posted by www123 at 2011-07-29 20:10:53 on Problem 2411
In Reply To:再来一个25行的插头DP的AC代码,具体就不解释了XD Posted by:Sayakiss at 2010-08-10 09:57:09
> #include<iostream>
> #include<cstring>
> using namespace std;
> long long f[2][1<<12],i,j,ps,p=0,c=1,n,m;
> int main()
> {
> 	while (scanf("%d%d",&n,&m),n!=0)
> 	{
> 	memset(f[c],0,sizeof(f[c]));
> 	f[c][(1<<m)-1]=1;
> 	for (i=0;i<n;i++)
> 		for (j=0;j<m;j++)
> 		{
> 			swap(p,c);memset(f[c],0,sizeof(f[c]));
> 			for (ps=0;ps<1<<m;ps++)
> 			if (f[p][ps])
> 			{
> 				if (j>0&&(!(ps&(1<<j-1)))&&(ps&(1<<j))) f[c][ps|1<<(j-1)]+=f[p][ps];
> 				if (!(ps&1<<j)) f[c][ps|1<<j]+=f[p][ps];
> 				if (ps&1<<j) f[c][ps^1<<j]+=f[p][ps];
> 			}
> 		}
> 	printf("%lld\n",f[c][(1<<m)-1]);
> 	}
> }

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator