POJ 2695 The Pilots Brothers' refrigerator(神奇的规律)
转载请注明出处:http://blog.csdn.net/a1dark
分析:如果想要将一个“+”翻转成“-”,那么必然会把对应的行和列上的所有点翻转一次、由于一个点翻偶数次就相当于不翻转、所以我需要统计“+”、然后将对应行和列的值+1、最后统计奇数值的个数、便是要翻转的点、
#include<stdio.h>
int mpt[5][5];
int main(){
char ch;
for(int i=1;i<=4;i++){
for(int j=1;j<=4;j++){
scanf("%c",&ch);
if(ch=='+'){
mpt[i][j]++;
for(int k=1;k<=4;k++){
mpt[i][k]++;
mpt[k][j]++;
}
}
}
getchar();
}
int step=0;
for(int i=1;i<=4;i++)
for(int j=1;j<=4;j++)
if(mpt[i][j]%2!=0)
step++;
printf("%d\n",step);
for(int i=1;i<=4;i++)
for(int j=1;j<=4;j++)
if(mpt[i][j]%2!=0)
printf("%d %d\n",i,j);
return 0;
}
POJ 2695 The Pilots Brothers' refrigerator(神奇的规律)的更多相关文章
- 枚举 POJ 2965 The Pilots Brothers' refrigerator
题目地址:http://poj.org/problem?id=2965 /* 题意:4*4的矩形,改变任意点,把所有'+'变成'-',,每一次同行同列的都会反转,求最小步数,并打印方案 DFS:把'+ ...
- 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 (dfs)
The Pilots Brothers' refrigerator Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 17450 ...
- POJ:2695-The Pilots Brothers' refrigerator
题目链接:http://poj.org/problem?id=2965 The Pilots Brothers' refrigerator Time Limit: 1000MS Memory Limi ...
- 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 - 2965 The Pilots Brothers' refrigerator(压位+bfs)
The game “The Pilots Brothers: following the stripy elephant” has a quest where a player needs to op ...
- poj 2965 The Pilots Brothers' refrigerator枚举(bfs+位运算)
//题目:http://poj.org/problem?id=2965//题意:电冰箱有16个把手,每个把手两种状态(开‘-’或关‘+’),只有在所有把手都打开时,门才开,输入数据是个4*4的矩阵,因 ...
随机推荐
- scanf函数和printf函数
C程序实现输出和输入的 主要是printf函数 和 scanf函数,这两个函数是格式输入输出 格式声明由%和格式字符组成 如%d,%f 格式字符: d格式符:用来输出一个有符号的十进制整数 c格式 ...
- BZOJ 1565: [NOI2009]植物大战僵尸( 最小割 )
先拓扑排序搞出合法的, 然后就是最大权闭合图模型了.... --------------------------------------------------------------------- ...
- 《JavaScript+DOM编程艺术》的摘要(一)---基本知识点
保持良好的编程习惯:在同一脚本中,保持引号的一致性,都用单引 var mood = "don\"t worry";alert(mood); 数组:var arr=Arra ...
- Asp.Net 禁用cookie后使用session
原文地址:http://www.c-sharpcorner.com/UploadFile/deepak.sharma00/using-cookie-less-session-in-Asp-Net/ H ...
- MySQL show binglog event in 'log_name'
二进制日志文件记录的内容:记录表的更改. 二进制日志文件记录的形式:基于语句的复制.基于行的复制. 两种记录形式的优点与不足: 基于语句的复制-->它不能保证复制的正确性.如随机函数可能在两台机 ...
- grunt安装使用简介
grunt是一个基于任务的实现自动化工作流的平台 安装 npm uninstall grunt -g //卸载grunt npm install grunt-cli -g //安装grunt-cli ...
- Initialization failed for block pool Block pool(转载)
2014-06-18 20:34:59,622 FATAL org.apache.hadoop.hdfs.server.datanode.DataNode: Initialization failed ...
- WebGL是一种3D绘图标准,这种绘图技术标准允许把JavaScript和OpenGL ES 2.0结合在一起
WebGL是一种3D绘图标准,这种绘图技术标准允许把JavaScript和OpenGL ES 2.0结合在一起,通过增加OpenGL ES 2.0的一个JavaScript绑定,WebGL可以为HTM ...
- HDU 2167 Pebbles
题目大意:有个N*N( 3<=N<=15 )方阵, 可从中若干个数, 使其总和最大.取数要求, 当某一个数被选, 其周围8个数都不能选. 题解:记s数组为合法状态,即没有相邻的数字同时被选 ...
- easyui使用总结
(一)datagrid 1.jquery的easyui中的datagrid刷新时的问题 在你的页面里增加2个class样式: .datagrid-mask{ opacity:0; ...