【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 ...
随机推荐
- c# 常用 Common
/// <summary> /// md5加密字符串 /// </summary> /// <param name="message">< ...
- PHP--选择排序
<?php /** * 选择排序(从小到大)的思想:每一次从待排序的数据中选出最小的,放在待排序的起始位置. */ $arr = array(23, 42, 21, 8, 4, 2, 3, 1) ...
- layer iframe层ajax回调弹出layer.msg()
ajax success方法 success: function(data){ layer.msg("输入你需要的提示",{time:1000,end:function(){ // ...
- 运行jar包的命令
windows下使用java -jar xxx.jar运行,linux下使用nohup java -jar xxx.jar & 如果想停止jar运行,ps -ef查看进程(进程多的话也可以加上 ...
- 22万个木箱!TWaver 3D极限压榨
打开个门户网站都千呼万唤,我们还能期待网页上的3D技术会有“酣畅淋漓”.“一气呵成”的感受吗?也许现在还差点火候.但是HTML5.WebGL等技术一直在飞速的发展,可能很快你就会惊讶它的能力.现在,我 ...
- 如何在 CentOS 7 上安装 Nginx
本文首发:开发指南:如何在 CentOS 7 上安装 Nginx Nginx 读作 engine x, 是一个免费的.开源的.高性能的 HTTP 和反向代理服务,主要负责负载一些访问量比较大的站点. ...
- CCF201503-2 数字排序 java(100分)
试题编号: 201503-2 试题名称: 数字排序 时间限制: 1.0s 内存限制: 256.0MB 问题描述: 问题描述 给定n个整数,请统计出每个整数出现的次数,按出现次数从多到少的顺序输出. 输 ...
- ubuntu jdk和tomcat配置
先查看linux的版通过file /sbin/init命令,下载对应版本的jdk. 我的ubuntu是64位的(桌面系统),所以下载的是jdk-7u71-linux-x64.tar.gz 在home的 ...
- 洛谷 2777 [AHOI2016初中组]自行车比赛
[题解] 为了让某个选手能够获得总分第一,就让他最后一天的得分是n,并且让别的选手的得分的最大值尽量小.于是我们先把目前积分排序,并且让他们最后一天的排名刚好与积分排名相反.即某个积分排名为X的人最后 ...
- JRebel 7.1.5 插件下载 安装 激活 结合 IntelliJ IDEA--自动编译进行热部署---
Intellij IDEA 安装和配置jrebel进行项目的热部署 https://www.cnblogs.com/a8457013/p/7866625.html Intellij IDEA 使用jr ...