【POJ 2965】 The Pilots Brothers' refrigerator
【题目链接】
http://poj.org/problem?id=2965
【算法】
位运算
【代码】
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cerrno>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <limits>
#include <list>
#include <map>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <utility>
#include <vector>
#include <cwchar>
#include <cwctype>
#include <stack>
#include <limits.h>
using namespace std;
const int MASK = ; int i,j,tmp,s,mn,p,sum;
int a[];
char c; inline int calc(int x,int y)
{
int pos = * x + y - ;
int ret = ;
int tmp = pos;
while (tmp < * x)
{
ret |= ( << tmp);
tmp++;
}
tmp = pos;
while (tmp >= * x - )
{
ret |= ( << tmp);
tmp--;
}
tmp = pos;
while (tmp < )
{
ret |= ( << tmp);
tmp += ;
}
tmp = pos;
while (tmp >= y - )
{
ret |= ( << tmp);
tmp -= ;
}
return ret;
} int main()
{ for (i = ; i <= ; i++)
{
for (j = ; j <= ; j++)
{
a[*i+j-] = calc(i,j);
}
}
for (i = ; i < ; i++)
{
scanf("%c",&c);
if (c == '-') s |= ( << i);
if (i % == ) scanf("%c",&c);
}
mn = MASK;
for (i = ; i <= MASK; i++)
{
tmp = s; sum = ;
for (j = ; j < ; j++)
{
if (i & ( << j))
{
sum++;
tmp ^= a[j];
}
}
if (tmp == MASK && sum < mn)
{
mn = sum;
p = i;
}
}
printf("%d\n",mn);
for (i = ; i < ; i++)
{
if (p & ( << i))
printf("%d %d\n",i/+,i%+);
} return ; }
【POJ 2965】 The Pilots Brothers' refrigerator的更多相关文章
- POJ 2965:The Pilots Brothers' refrigerator
		
id=2965">The Pilots Brothers' refrigerator Time Limit: 1000MS Memory Limit: 65536K Total S ...
 - 【POJ2965】The Pilots Brothers' refrigerator
		
题目传送门 本题知识点:深度优先搜索 + 暴力枚举 + 回溯 + 栈 如果对以上知识点还不熟悉的同学建议先做做 POJ1753 (本题是1753的提高版)(附 POJ1753博客) 以下默认您已ACP ...
 - POJ 2965. The Pilots Brothers' refrigerator 枚举or爆搜or分治
		
The Pilots Brothers' refrigerator Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 22286 ...
 - 枚举 POJ 2965 The Pilots Brothers' refrigerator
		
题目地址:http://poj.org/problem?id=2965 /* 题意:4*4的矩形,改变任意点,把所有'+'变成'-',,每一次同行同列的都会反转,求最小步数,并打印方案 DFS:把'+ ...
 - poj 2965 The Pilots Brothers' refrigerator (dfs)
		
The Pilots Brothers' refrigerator Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 17450 ...
 - POJ 2965 The Pilots Brothers' refrigerator 暴力 难度:1
		
The Pilots Brothers' refrigerator Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 16868 ...
 - POJ 2965 The Pilots Brothers' refrigerator 位运算枚举
		
The Pilots Brothers' refrigerator Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 151 ...
 - POJ  2965  The Pilots Brothers' refrigerator (DFS)
		
The Pilots Brothers' refrigerator Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 15136 ...
 - POJ:2695-The Pilots Brothers' refrigerator
		
题目链接:http://poj.org/problem?id=2965 The Pilots Brothers' refrigerator Time Limit: 1000MS Memory Limi ...
 
随机推荐
- Functional language 函数
			
一.什么是函数式语言? 函数式语言一类程序设计语言,是一种非冯·诺伊曼式的程序设计语言.函数式语言主要成分是原始函数.定义函数和函数型.这种语言具有较强的组织数据结构的能力,可以把某一数据 ...
 - php中 如何找到session 的保存位置
			
[前言] 刚刚想测试FQ操作,需要删除session,这里记录分享下 [主体] (1)想要查看session保存的目录,需要先找到 php.ini配置文件 (2)在php.ini文件中查找 sessi ...
 - 【转载】eclipse设置护眼色详细教程
			
先上一张效果图: 下面开始设置: 首先设置代码区的背景色: Window–>preference-->General-->Editors-->Test Editors ...
 - java命令行版的ATM
			
import java.util.*;public class Jatm{ static String user = "123"; static String password = ...
 - 爬虫之BeautifulSoup库
			
文档:https://beautifulsoup.readthedocs.io/zh_CN/latest/ 一.开始 解析库 # 安装解析库 pip3 install lxml pip3 instal ...
 - 多校1010 Taotao Picks Apples
			
>>点击进入原题<< 思路:题解很有意思,适合线段树进阶 #include<cstdio> #include<cmath> #include<cs ...
 - docker  CE 的安装
			
一.Docker CE的安装1.先决条件运行环境:Ubuntu 64位或者其他支持Docker的64位系统运行配置,linux内核版本必须大于 3.10,否则会因为缺少容器运行所需的功能而出错. 2. ...
 - Hyper-v交换机添加出错解决方法
			
这个问题中文找不到解决方法,只能重新安装系统了 重新安装系统后,按照顺序操作,不要去动设备管理器中的东西,也不用动驱动,先删除虚拟机的网络连接,在删除虚拟交换机就可以了,没有再出现问题
 - 洛谷—— P2149 [SDOI2009]Elaxia的路线
			
https://www.luogu.org/problem/show?pid=2149 题目描述 最近,Elaxia和w的关系特别好,他们很想整天在一起,但是大学的学习太紧张了,他们 必须合理地安排两 ...
 - P1656 炸铁路   洛谷
			
https://www.luogu.org/problem/show?pid=1656 题目描述 因为某国被某红色政权残酷的高压暴力统治.美国派出将军uim,对该国进行战略性措施,以解救涂炭的生灵. ...