标签:
Time Limit: 1000MS | Memory Limit: 65536KB | 64bit IO Format: %I64d & %I64u |
Description
Input
Output
Sample Input
input | output |
---|---|
0 1 0 1 1 0 1 |
0 1 0 0 1 0 1 |
1 1 1 1 1 1 1 |
1 1 1 1 1 1 1 |
直接枚举
#include<iostream> using namespace std; int a[10]; bool ok(int a1, int a2, int a3, int a4, int b1,int b2, int b3) { if ((a1 + a2 + a4) % 2 != b3) return false; if ((a1 + a3 + a4) % 2 != b2) return false; if ((a2 + a3 + a4) % 2 != b1) return false; return true; } int main() { while (cin>>a[0]) { for (int i = 1; i < 7; i++) cin >> a[i]; if (ok(a[0], a[1], a[2], a[3], a[4], a[5], a[6])) { for (int i = 0; i < 7; i++) { if (i) cout << " "; cout << a[i]; } cout << endl; continue; } for (int i = 0; i < 7; i++) { a[i] = 1^a[i]; if (ok(a[0], a[1], a[2], a[3], a[4], a[5], a[6])) { for (int i = 0; i < 7; i++) { if (i) cout << " "; cout << a[i]; } cout << endl; break; } a[i] = 1^a[i]; } } }
标签:
原文地址:http://blog.csdn.net/qq_18738333/article/details/45157139