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 KatrineYang at 2016-07-10 17:49:54 on Problem 1063
#include <iostream>
using namespace std;

int main() {
	int cases;
	cin >> cases;
	for(int ii = 0; ii < cases; ii++){
		int num;
		cin >> num;
		if(num%2 == 1){
			int fei;
			for(int i = 0; i < num; i++) cin >> fei;
			cout << "YES" << endl;
		}
		else{
			int feis[32];
			for(int i = 0; i < num; i++) cin >> feis[i];
			int ji = 0, ou = 0;
			for(int i = 0; i < num; i+= 2) ou += (feis[i]==1);
			for(int i = 1; i < num; i+= 2) ji += (feis[i]==1);
			if(ou - ji == 1 || ou == ji || ou - ji == -1) cout << "YES" << endl;
			else cout << "NO" << 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