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 55 at 2009-02-19 13:34:35 on Problem 1014
In Reply To:大家看一下这样的构想对不对 Posted by:55 at 2009-02-19 13:30:55
如果6的位置上是偶数置0
如果是奇数置1
考虑6=5+1=4+2=4+1+1=3+3=3+2+1=3+1+1+1=2+2+2=2+2+1+1=2+1+1+1+1=1+1+1+1+1+1
在分别在各数字对应减去
代码如下:
#include<stdio.h>
int f(int t)
{
	if(t==0) return 1;
	else return 0;
}
int f2(int a,int t)
{
	int sum=0;
	if(t==0) return f(a%2);
	if(a>=2) sum+=f((a-2)%2);
	if(sum>=1) return 1;
	else return 0;
}
int f3(int a,int b,int t)
{
	int sum=0;
	if(t==0) return f2(a,b%2);
	if(a>=1&&b>=1) sum+=f2(a-1,(b-1)%2);
	if(a>=3)       sum+=f2(a-3,b%2);
	if(sum>=1) return 1;
	else return 0;
}
int f4(int a,int b,int c,int t)
{
	int sum=0;
	if(t==0) return f3(a,b,c%2);
	if(a>=1&&c>=1)  sum+=f3(a-1,b,(c-1)%2);
	if(b>=2)        sum+=f3(a,b-2,c%2);
	if(a>=2&&b>=1)  sum+=f3(a-2,b-1,c%2);
	if(a>=4)        sum+=f3(a-4,b,c%2);
	if(sum>=1) return 1;
	else return 0;
}
int f5(int a,int b,int c,int d,int t)
{
	int sum=0;
	if(t==0) return f4(a,b,c,d%2);
	if(a>=1&&d>=1)	sum+=f4(a-1,b,c,(d-1)%2);
	if(b>=1&&c>=1)	sum+=f4(a,b-1,c-1,d%2);
	if(a>=2&&c>=1)	sum+=f4(a-2,b,c-1,d%2);
	if(a>=1&&b>=2)	sum+=f4(a-1,b-2,c,d%2);
	if(a>=3&&b>=1)	sum+=f4(a-3,b-1,c,d%2);
	if(a>=5)		sum+=f4(a-5,b,c,d%2);
	if(sum>=1) return 1;
	else return 0;
}

int f6(int a,int b,int c,int d,int e,int t)
{
	int sum=0;
	if(t==0) return f5(a,b,c,d,e%2);
	if(a>=1&&e>=1)	sum+=f5(a-1,b,c,d,(e-1)%2);
	if(b>=1&&d>=1)	sum+=f5(a,b-1,c,d-1,e%2);
	if(a>=2&&d>=1)	sum+=f5(a-2,b,c,d-1,e%2);
	if(c>=2)		sum+=f5(a,b,c-2,d,e%2);
	if(a>=1&&b>=1&&c>=1) sum+=f5(a-1,b-1,c-1,d,e%2);
	if(a>=3&&c>=1)	sum+=f5(a-3,b,c-1,d,e%2);
	if(b>=3)    	sum+=f5(a,b-3,c,d,e%2);
	if(a>=2&&b>=2)	sum+=f5(a-2,b-2,c,d,e%2);
	if(a>=4&&b>=1)	sum+=f5(a-4,b-1,c,d,e%2);
	if(a>=6)		sum+=f5(a-6,b,c,d,e%2);
	if(sum>=1) return 1;
	else return 0;
}
int main()
{
	int a,b,c,d,e,f,t;
	__int64 sum;
	t=1;
	scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f);
	while(1)
	{
		if(a==0&&b==0&&c==0&&d==0&&e==0&&f==0) break;
		sum=a*1+b*2+c*3+d*4+e*5+f*6;
		if(sum%2==1)
		{
			printf("Collection #%d:\n",t++);
			printf("Can't be divided.\n\n");
			scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f);
			continue;
		}
		printf("Collection #%d:\n",t++);
		if(f6(a,b,c,d,e,f%2)) printf("Can be divided.\n\n");
		else printf("Can't be divided.\n\n");
		scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f);
	}
	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