作者:Vin-莹持_366 | 来源:互联网 | 2023-05-17 20:54
Step1 Problem:
每次让三个数翻转,结果全为0,最少需要翻转几次?
Step2 Ideas:
构造异或方程组,求出自由元,枚举自由元所有情况,找出最小解。
Step3 Code:
#include
#include
#include
using namespace std;
const int N = 25;
const int inf = 0x3f3f3f3f;
int data[N][N], lib[N];
int x[5] = {1, -1, 0};
bool ok(int x, int y)
{
if(x >= 0 && x <20 && y >= 0 && y <20) return 1;
else return 0;
}
int Gauss(int n)
{
memset(lib, 0, sizeof(lib));
int r = 0, rst = 0;
for(int i = 0; i for(int j = r; j