转载请注明出处: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. Java学习之String对象为什么是不可变的

    转自:http://www.2cto.com/kf/201401/272974.html,感谢作者的总结 什么是不可变对象? 众所周知, 在Java中, String类是不可变的.那么到底什么是不可变 ...

  2. 网络子系统48_ip协议数据帧的发送

    //ip协议与l4协议接口,l4通过此接口向下l3传递数据帧 //函数主要任务: // 1.通过路由子系统路由封包 // 2.填充l3报头 // 3.ip分片 // 4.计算校验和 // 5.衔接邻居 ...

  3. Easyui + jQuery表单提交 给 Controller patr1

    2014-11-15  总结上周在公司开发所用到的技术,由于是刚找的工作(一个大三实习生)+自己的技术菜,有很多地方都是怎么想就怎么实现的, 如果你有什么更好的解决方法,在看见这篇博客的时候,希望你能 ...

  4. SQL1-(增删改查、常用函数)

    USE flowershopdb --全球唯一标识符(GUID UUID) SELECT NEWID() --增删改查 --INSERT [INTO] <表名> [列名] VALUES & ...

  5. Pro/Engineer wildfire 5.0 野火版系列下载及安装方法

    三.PTC Pro/Engineer wildfire 5.0 M030 野火版最新版 DVD 下载(多国语言) 1.野火下载站下载32&64位下载:[32位] http://down.pro ...

  6. C++面试经常涉及的概念1

    1.new.delete.malloc.free关系 delete会调用对象的析构函数,和new对应.free只会释放内存,new调用构造函数.malloc与free是C++/C语言的标准库函数,ne ...

  7. java的常见异常与错误总结

    算术异常类:ArithmeticExecption 空指针异常类:NullPointerException 类型强制转换异常:ClassCastException 数组负下标异常:NegativeAr ...

  8. 【c语言】推断一个数是不是2的n次方

    // 推断一个数是不是2的n次方 #include <stdio.h> void judge_n(int a) { int b = a - 1; if ((a & b) == 0) ...

  9. ANDROID对文件的操作

    import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.Inp ...

  10. Android SQLite之乐学成语项目数据库存储

    一.SQLite是什么?为什么要用SQLite?SQLite有什么特点?(下面小编一 一解答) ①SQLite是一个轻量级的关系型数据库,运算速度快,占用资源少,很适合在移动设备上使用, 不仅支持 标 ...