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

请指教……

Posted by custqi at 2010-10-17 19:07:01
/*先将每个大于2的求余,然后没居所有可能组合,6=1+5(a[2]=a[3]=a[4]=0) || 6=2+4(a[1]=a[3]=a[5]=0)*/
#include<iostream>
using namespace std;

int a[6] = {0};
int solve();

int main()
{
	int num = 0;
	while(cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4] >> a[5])
	{
		num++;
		int flag = 0;
		for(int i=0;i<6;i++)
		{
			if(a[i]>=2)
			{
				a[i] = a[i]%2;
			}
		}
		flag = solve();
		if(flag==1)
		{
			cout << "Collection #" << num << endl;
		    cout << "Can be divided" << '\n' << endl;
		}
		if(flag==0)
		{
			cout << "Collection #" << num << endl;
		    printf("Can't be divided.\n\n");
		}
	}
	return 0;
}

int solve()
{
	if( (a[5]==1 && a[1]==1 && a[3]==1 && a[0]==0 && a[4]==0 && a[2]==0) || (a[5]==1 && a[1]==0 && a[3]==0 && a[0]==1 && a[4]==1 && a[2]==0) )
		return 1;
	if( a[3]==1 && a[0]==1 && a[2]==1 && a[4]==0 && a[5]==0 && a[1]==0 )
		return 1;
	if( (a[4]==1 && a[1]==1 && a[2]==1 && a[0]==0 && a[3]==0 && a[5]==0) || (a[4]==1 && a[0]==1 && a[3]==1 && a[5]==0 && a[1]==0 && a[2]==0) )
		return 1;
	if( (a[2]==1 && a[0]==1 && a[1]==1 && a[3]==0 && a[4]==0 && a[5]==0) )
		return 1;
	else
		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