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

这题比1222水多了

Posted by KatrineYang at 2016-08-19 04:16:44 on Problem 3185
In Reply To:看到这个题目...让我想起了1222.... Posted by:Sempr at 2007-01-25 17:09:15
#include <iostream>
using namespace std;

int main() {
	int a[20];
	for(int i = 0; i < 20; i++){
		cin >> a[i];
	}
	int x[20];
	int res = 21;
	int cnt = 0;
	for(x[0] = 0; x[0] <= 1; x[0]++){
		cnt = x[0];
		x[1] = (a[0]+x[0])%2;
		cnt += x[1];
		for(int i = 2; i < 20; i++) {
			x[i] = (x[i-1]+x[i-2]+a[i-1])%2;
			cnt += x[i];
		}
		if((x[18]+x[19]+a[19])%2 == 0 && cnt < res){
			res = cnt;
		}
	}
	cout << res;
	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