转载请注明出处: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(神奇的规律)的更多相关文章

  1. 枚举 POJ 2965 The Pilots Brothers' refrigerator

    题目地址:http://poj.org/problem?id=2965 /* 题意:4*4的矩形,改变任意点,把所有'+'变成'-',,每一次同行同列的都会反转,求最小步数,并打印方案 DFS:把'+ ...

  2. POJ 2965. The Pilots Brothers' refrigerator 枚举or爆搜or分治

    The Pilots Brothers' refrigerator Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 22286 ...

  3. poj 2965 The Pilots Brothers' refrigerator (dfs)

    The Pilots Brothers' refrigerator Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 17450 ...

  4. POJ:2695-The Pilots Brothers' refrigerator

    题目链接:http://poj.org/problem?id=2965 The Pilots Brothers' refrigerator Time Limit: 1000MS Memory Limi ...

  5. POJ 2965 The Pilots Brothers' refrigerator 暴力 难度:1

    The Pilots Brothers' refrigerator Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 16868 ...

  6. POJ 2965 The Pilots Brothers' refrigerator 位运算枚举

      The Pilots Brothers' refrigerator Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 151 ...

  7. POJ 2965 The Pilots Brothers' refrigerator (DFS)

    The Pilots Brothers' refrigerator Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 15136 ...

  8. 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 ...

  9. poj 2965 The Pilots Brothers' refrigerator枚举(bfs+位运算)

    //题目:http://poj.org/problem?id=2965//题意:电冰箱有16个把手,每个把手两种状态(开‘-’或关‘+’),只有在所有把手都打开时,门才开,输入数据是个4*4的矩阵,因 ...

随机推荐

  1. window权限 及c++实现 【网摘】(转)

    from : http://blog.csdn.net/zipper9527/article/details/6256459 http://www.lihuasoft.net/article/show ...

  2. BZOJ 4321: queue2( dp )

    dp(i, j, 1)表示前i个, 有j对是不合法的, i和i-1是在一起的. dp(i, j, 0)表示前i个, 有j对是不合法的, i和i-1不在一起的. 转移我们只需考虑是多了一对不合法的还是少 ...

  3. 页面打开直接执行a点击事件

    <script> window.onload = function(){ function autoclick(){ var url = document.getElementById(' ...

  4. phpcms新增栏目字段_phpcms添加栏目属性

    先做个广告 WEB网站开发 APP后台开发 安卓开发 物流系统 时时彩系统开发 电商系统开发 微信开发 请联系我 QQ 13266112 or 184377367 phpcms新增栏目字段_phpcm ...

  5. java附件上传下载大字段版

    public int up2(Map map) { StringBuffer insertSQL = new StringBuffer(); insertSQL.append("insert ...

  6. OSCache报错error while trying to flush writer

    Struts2.3+spring3+hibernate3开发现在想在原有基础上使用 oscache提高性能,使用中发现问题例如:使用struts2标签<cache:cache time=&quo ...

  7. IOS开发笔记 IOS如何访问通讯录

    IOS开发笔记  IOS如何访问通讯录 其实我是反对这类的需求,你说你读我的隐私,我肯定不愿意的. 幸好ios6.0 以后给了个权限控制.当打开app的时候你可以选择拒绝. 实现方法: [plain] ...

  8. android 关于多任务下载问题

    关于多任务下载问题    近期项目中,遇到一个问题,列表数据中的图片地址是一个需要下载JS再解析的字段,之前的图片下载是一个异步的过程,由一个队列处理. Android系统以不同寻常的方式处理多个应用 ...

  9. IOS学习之蓝牙4.0 BLE

    IOS学习也一段时间了,该上点干货了.前段时间研究了一下IOS蓝牙通讯相关的东西,把研究的一个成果给大家分享一下. 一 项目背景 简单介绍一下做的东西,设备是一个金融刷卡器,通过蓝牙与iphone手机 ...

  10. 在MySQL中创建实现自增的序列(Sequence)的教程

    这篇文章主要介绍了在MySQL中创建实现自增的序列(Sequence)的教程,分别列举了两个实例并简单讨论了一些限制因素,需要的朋友可以参考下 项目应用中,曾有以下一个场景: 接口中要求发送一个int ...