博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Rikka with Chess(规律)
阅读量:6950 次
发布时间:2019-06-27

本文共 1430 字,大约阅读时间需要 4 分钟。

Rikka with Chess

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 84    Accepted Submission(s): 72

Problem Description
Yuta gives Rikka a chess board of size
 n×m.
As we all know, on a chess board, every cell is either black or white and every two cells that share a side have different colors.
Rikka can choose any rectangle formed by board squares and perform an inversion, every white cell becomes black, and vice versa.
Rikka wants to turn all cells into the same color, please tell Rikka the minimal number of inversions she need to achieve her goal.
 

 

Input
The first line contains a number
 T(T10) ——The number of the testcases.
Each testcase contains two numbers n,m(n109,m109).
 

 

Output
For each testcase, print a single number which represents the answer.
 

 

Sample Input
3 1 2 2 2 3 3
 

 

Sample Output
1 2 2
 
 
题解:很好找的规律,第二组数据:
101
010
101
把第二行反转
101
101
101
把第二列反转
111
111
111
由此可得:
直接行列减半取整即可;
代码:
#include
#include
#include
#include
#include
#include
using namespace std;const int INF=0x3f3f3f3f;#define mem(x,y) memset(x,y,sizeof(x))#define SI(x) scanf("%d",&x)#define PI(x) printf("%d",x)#define SD(x,y) scanf("%lf%lf",&x,&y)#define P_ printf(" ")const int MAXN=1010;typedef long long LL;int main(){ int T,N,M; SI(T); while(T--){ SI(N); SI(M); printf("%d\n",N/2+M/2); } return 0;}

 

转载地址:http://itkil.baihongyu.com/

你可能感兴趣的文章
ubuntu 绑定固定ip
查看>>
(转)linux下fork的运行机制
查看>>
vue-cli搭建及项目目录结构
查看>>
springboot秒杀课程学习整理1-5
查看>>
css中display:none与visibility: hidden的区别
查看>>
本人精心收集的近80个国内最好的嵌入式技术相关网站和论坛和博客
查看>>
Python Package——wget
查看>>
在python下进行pdf的合并
查看>>
pyextend库-unpack列表集合字符串解包函数
查看>>
NGUI通过点击按钮来移动面板位置,实现翻页功能
查看>>
Windows版本redis高可用方案探究
查看>>
Android ---------- TabLayout 实战 (一)
查看>>
layoutSubviews在何时调用
查看>>
Hibernate快速入门
查看>>
第二条:遇到多个构造器参数时考虑使用构建器
查看>>
Android Studio使用时源码到处报红色警告,运行时又没错
查看>>
如何在apache加载php模块
查看>>
多媒体开发之---h264 server rtsp
查看>>
嵌入式开发之davinci--- 8168 电源调试总结
查看>>
图像处理之基础---频域分析
查看>>