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 |
这题比1222水多了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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator