uva 11464 偶数矩阵

该博客介绍了如何解决UVA 11464编程问题,主要内容是通过枚举矩阵第一行的2^n种可能状态,以最小次数更改0为1,确保矩阵中每个元素相邻数字之和为偶数。文章探讨了相关算法和策略。
摘要由CSDN通过智能技术生成

题意:给定一个矩阵,其中元素为 0或者1

            花最少次数 改变其中的0 到1, 使得每个元素上下左右的数字之和为 偶数

 

方法:枚举第一行2^n 种情况,最后判断最后一行是否满足

 

#include <iostream>
#include <vector>
#include <map>
#include <list>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cctype>
#include <cstdio>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <cstring>
#include <queue>
using namespace std;

///宏定义
const int INF = 20000000;
const int maxn = 20;
///全局变量 和 函数
//
int T;
int board[maxn][maxn];
int board1[maxn][maxn];
int n;
int cnt;
bool test()
{
	int i, j;
	for (i = 1; i <= n - 1; i++)
	{
		for (j = 1; j <= n; j++)
		{
			//推导下一行的状态
		
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值