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:why OPE

Posted by cpp0600648238 at 2007-05-02 17:38:15 on Problem 1601
In Reply To:why OPE Posted by:BJ051155 at 2007-04-20 23:02:00
不能while(1)。
> #include <iostream.h>
> #include <string.h>
> 
> int res[16];
> int a[12][16];
> int p;
> 
> int check(int id)
> {
> 	int i=0,j,sign;
> 	while(id)
> 	{
> 		res[i++]=id%2;
> 		id=id/2;
> 	}
> 	while(i<16)
> 		res[i++]=0;
> 	for(i=0;i<p;i++)
> 	{
> 		sign=0;
> 		for(j=0;j<16&&sign==0;j++)
> 			if(res[j]==a[i][j])
> 				sign=1;
> 		if(!sign)
> 			return 0;
> 	}
> 	return 1;
> 
> }
> 
> int main(int argc, char* argv[])
> {
> 	char r[33],c;
> 	int i,id;
> 	while(1)
> 	{
> 		p=0;
> 		while(cin>>r)
> 		{
> 			if(r[0]=='.')
> 				break;
> 			for(i=0;i<16;i++)
> 				a[p][i]=-1;
> 			for(i=1;i<strlen(r);i+=2)
> 				a[p][r[i]-65]=(r[i-1]=='+'?1:0);
> 			p++;
> 		}
> 		id=0;
> 		while(id<=65535)
> 		{
> 			if(check(id))
> 				break;
> 			id++;
> 		}
> 		if(id>65535)
> 			cout<<"No pizza can satisfy these requests."<<endl;
> 		else
> 		{
> 			if(!id)
> 				cout<<"Toppings: ";
> 			else
> 			{
> 				cout<<"Toppings: ";
> 				for(i=0;i<16;i++)
> 				if(res[i])
> 				{
> 					
> 					c=i+65;
> 					cout<<c;
> 				}
> 			}
> 			cout<<endl;
> 		}
> 			
> 	}
> 	return 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