Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
请有功夫的大虾看看问题在哪#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator