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:这么简单的一道暴搜花了一上午,47ms,贴代码!!!

Posted by 94ben at 2012-10-08 23:17:41 on Problem 1753
In Reply To:这么简单的一道暴搜花了一上午,47ms,贴代码!!! Posted by:xuchang at 2010-12-20 10:52:10
> #include <iostream>
> #include <math.h>
>  
> using namespace std;
> 
> void search(int cur,int dep);
> bool find=false;
> int flip[16]={51200,58368,29184,12544,35968,20032,10016,4880,2248,1252,626,305,140,77,39,19};
> int count=0;
> int finalans=16;
> int main()
> {
> 	char c ;
> 	int value=0;
> 	for(int i=0;i<16;) 
> 	{
> 		c=getchar();
> 		if(c=='b')
> 		{
> 			value+=pow(2.0,15-i);
> 			i++;
> 		}
> 		else if(c=='w')
> 		{
> 			i++;
> 		}
> 		else
> 		   continue;
> 	}
> 	search(value,0);
> 	if(!find)
> 		cout<<"Impossible"<<endl;
> 	else
> 		cout<<finalans<<endl;
> 	system("pause");
> 	return 0;
> }
> 
> void search(int cur,int dep)
> {
> 	if(cur==65535||cur==0)
> 	{
> 		find=true;
> 		if(count<finalans)
> 			finalans=count;
> 	}
> 	if(dep==16)
> 		return ;
> 	int temp=cur;
> 	cur=cur^flip[dep];
> 	count++;
> 	search(cur,dep+1);	
> 	count--;
> 	search(temp,dep+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