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 |
Re:枚举不完全...In Reply To:为什么wa?查不出来 我觉得思路挺简单的 Posted by:testjoan at 2006-05-20 21:54:33 > # include <iostream.h> > # include <memory.h> > > char plant[8][8]; > bool col[8]; > int c; > int n,k; > > void setchess(int,int); > > void main() > { > int i,j; > > while (1){ > cin>>n>>k; > cin.ignore(1000,'\n'); > if (n==-1 || k==-1) break; > for (i=0;i<n;i++){ > for (j=0;j<n;j++){ > cin>>plant[i][j]; > } > } > memset(col,0,sizeof(bool)*8); > c=0; > for (i=0;i<n;i++) setchess(i,k); > cout<<c<<endl; > } > } > > void setchess(int i,int nchess) > { > int j; > for (j=0;j<n;j++){ > if (plant[i][j] == '#' && col[j]==0) > { > col[j]=1; > nchess--; > if ( (i+1)<n && nchess>0 ) setchess(i+1,nchess); > else if (nchess==0) c++; > nchess++; > col[j]=0; > } > } > } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator