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:枚举不完全...

Posted by mayp at 2007-03-14 22:27:32 on Problem 1321
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:
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