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 hudedi at 2005-12-08 07:43:19 on Problem 1063
In Reply To:请有功夫的大虾看看问题在哪 Posted by:C0400204068 at 2004-03-21 16:50:30
> #include<stdio.h>
> int main()
> {
> 	int  len, t, odd, dou ,s  ,c;
> 	long num , m ,temp[60];
> 	scanf ( "%ld" , &num ) ; //组数
> 	if (num==0)    return 0;
> 	else
> 	{
> 		for( m=0 ; m<num ; m++ )
> 		{   
> 			dou=odd=0;
> 			scanf("%d", &len );//组内数字个数
> 			if(len%2==0)       //偶数
> 			{	
> 				for( t=0;t<len;t++)
> 				{
> 					scanf("%d",&s);				
> 					if(s==1 && t%2==0)
> 						dou++;
> 					else if(s==1 && t%2==1)
> 						odd++;
> 				}				
> 				if(odd-dou==-1 || odd==dou || odd-dou==1)	printf("YES\n");	
> 				else 	printf("NO\n");
> 			}
> 			else                //奇数
> 			{
> 				for( t=0;t<len;t++)
> 				{
> 					scanf("%d",temp+t);  
> 					temp[t+len]=temp[t];           //循环赋值
> 				}
> 				for( t=0;t<len;t++)
> 				{						  
> 					if(temp[t]==1 && t%2==0)
> 						dou++;
> 					else if(temp[t]==1 && t%2==1)
> 						odd++;
> 				}
> 				if(odd-dou==-1 || odd==dou || odd-dou==1)	
> 					printf("YES\n");	
> 				else 
> 				{
> 					c=0;
> 					for( s=0;s<len;s++)            //循环求证
> 					{
> 						for( t=s;t<len+s;t++)
> 						{						  
> 							if(temp[t]==1 && t%2==0)
> 								dou++;
> 							else if(temp[t]==1 && t%2==1)
> 								odd++;
> 						}
> 						if(odd-dou==-1 || odd==dou || odd-dou==1)
> 						{	
> 							printf("YES\n");
> 							c=1; break ;
> 						}	
> 						
> 					}
> 					if(c==0) printf("NO\n");
> 					
> 				}
> 			}
> 		}
> 		return 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