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 |
言简意赅地AC#include<iostream> #include<cstring> using namespace std; long long dp[20][1<<11]; int n,m; void dfs(int s,int row,int line,long long val) { int i,k; k=m-1; dp[row][line]+=val; for(i=s;i<k;i++) if((line>>i&1)==0) if((line>>i+1&1)==0) dfs(i+2,row,line|(1<<i)|(1<<i+1),val); } int main() { int i,j,k; while(cin>>n>>m) { if(n==0&&m==0) break; memset(dp,0,sizeof(dp)); dfs(0,0,0,1); k=1<<m; for(i=1;i<n;i++) for(j=0;j<k;j++) dfs(0,i,k-1^j,dp[i-1][j]); cout<<dp[n-1][k-1]<<endl; } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator