| ||||||||||
| 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 <iostream>
#include <stdio.h>
#include <string.h>
#define MASK (0xfffff << 1)
using namespace std;
int count(int bowl, int n, int nflips) {
if ((bowl & MASK) == 0) return nflips;
if (n == 1) return 99999;
if (bowl & (1 << n)) return count(bowl ^ (7 << (n - 2)), n - 1, nflips + 1);
return count(bowl, n - 1, nflips);
}
int main() {
int i, bit, bowl = 0;
for (i = 0; i < 20; i++) {
scanf("%d", &bit);
bowl = (bowl << 1) | bit;
}
bowl = bowl << 1;
printf("%d\n", min(count(bowl ^ (3 << 19), 20, 1), count(bowl, 20, 0)));
return 0;
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator