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(T≤10) ——The number of the testcases.
Each testcase contains two numbers n,m(n≤109,m≤109).
 
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<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
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=;
typedef long long LL;
int main(){
int T,N,M;
SI(T);
while(T--){
SI(N);
SI(M);
printf("%d\n",N/+M/);
}
return ;
}

Rikka with Chess(规律)的更多相关文章

  1. hdu 5630 Rikka with Chess

    来自官方题解: AC代码: #pragma comment(linker, "/STACK:1024000000,1024000000") #include<iostream ...

  2. hdoj--5630--Rikka with Chess(规律题)

     Rikka with Chess Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Othe ...

  3. BestCoder Round #73 (div.2)(hdu 5630)

    Rikka with Chess Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) ...

  4. BestCoder Round #73 (div.2)

    1001 Rikka with Chess ans = n / 2 + m / 2 1002 Rikka with Graph 题意:n + 1条边,问减去至少一条使剩下的图连通的方案数. 分析:原来 ...

  5. hdu5630 BestCoder Round #73 (div.2)

    Rikka with Chess  Accepts: 393  Submissions: 548  Time Limit: 2000/1000 MS (Java/Others)  Memory Lim ...

  6. 2017ACM暑期多校联合训练 - Team 5 1006 HDU 5205 Rikka with Graph (找规律)

    题目链接 Problem Description As we know, Rikka is poor at math. Yuta is worrying about this situation, s ...

  7. 2017 ACM暑期多校联合训练 - Team 5 1008 HDU 6092 Rikka with Subset (找规律)

    题目链接 Problem Description As we know, Rikka is poor at math. Yuta is worrying about this situation, s ...

  8. codeforces Gym 100418D BOPC 打表找规律,求逆元

    BOPCTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/view.action?c ...

  9. HDU 5794 - A Simple Chess

    HDU 5794 - A Simple Chess题意: 马(象棋)初始位置在(1,1), 现在要走到(n,m), 问有几种走法 棋盘上有r个障碍物, 该位置不能走, 并规定只能走右下方 数据范围: ...

随机推荐

  1. JLINK烧写BIN文件到nand、norflash、SDRAM

    1. 简要说明 JLink的调试功能.烧写Flash的功能都很强大,但是对于S3C2410.S3C2440的Flash操作有些麻烦:烧写Nor Flash时需要设置SDRAM,否则速率很慢:烧写Nan ...

  2. struts 2 三目运算

    <s:set id="styleList" value="{'default','success','warning'}"/> <s:iter ...

  3. Python字符串与数字拼接

    Python不像JS或者PHP这种弱类型语言里在字符串连接时会自动转换类型,而是直接报错.要解决这个方法只有提前把int转成string,然后再拼接字符串即可. 如代码: 1 2 3 4 5 # co ...

  4. REST Web Server,REST介绍

    参考资料: 1.http://www.chinalivedoor.com/story/1123.html 2. Backbone.js 是一种重量级javascript  MVC 应用框架,通过Mod ...

  5. 微软Code Hunt答案(00-05)——沉迷娱乐的我

    昨天看到微软出的网游Code Hunt.o(∩_∩)o...哈哈,还不好好玩一吧,个人感觉不是一个模块比一个模块难的,Code Hunt是按功能划分.所以不要怕自己做不来.由于不同人特长不一样. 像A ...

  6. IOS-时间与字符串互相转换

    有时会遇到这种问题,须要把时间和时间戳互相转换 比方把"这种格式 或者是把""转换成"2014-07-16 15:54:36" 首先来第一个: 当前时 ...

  7. 树形dp-hdu-4714-Tree2cycle

    题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=4714 题目意思: 给一棵树,去掉一条边和增加一条边的花费都为1,求最小的花费,使该树变成一个环. 解 ...

  8. Android上下左右滑动,显示底层布局

    转载博客地址:http://www.cnblogs.com/flyme2012/p/4106308.html 闲着没事做了一个小东西.Android的上下左右滑动,显示底层布局.可以做类似于QQ消息列 ...

  9. 解决VS2010打开Web页面时经常由于内存较低而导致VS2010自动关闭的问题

    在使用VS2010 开发Web应用程序的时候,经常打开一个Web页面进行编辑前台代码的时候要等待很久(甚至等了半天结果还挂掉,简直令人抓狂), 之前也在网上找了很多相关的方法,都没办法解决,今天无意中 ...

  10. Javascript 常用

    第一步,实现百度输入法的页面布局 <!DOCTYPE html> <html> <head> <meta charset="utf-8" ...