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. 05-3. 求a的连续和(15)

    输入两个整数a和n,a的范围是[0,9],n的范围是[1,8],求数列之和S = a+aa+aaa+...+aaa...a(n个a). 如a为2.n为8时输出的是2+22+222+...+222222 ...

  2. 探究adroid活动

    Intent用处 隐式使用intent,在被启动的activity的manifest文件配置该活动 在出发活动建立intent时就写好和 网页浏览器用new intent 时用Intent.ACTIO ...

  3. mit java open course assignment #4

    package come; public class Library { // Add the missing implementation to this class String realLoca ...

  4. Python学习笔记7-把函数当参数传递、指定可变参数

    把函数当参数传递 # 函数参数传递 # 面向对象编程就是把对象传来传去 # 面向函数编程就是把函数传来传去 def mytest(num): return num * 2 # # 不光可以传递变量,还 ...

  5. Magento - get Attribute Options of the dropdown type attribute

      $attribute_code = "color"; $attribute_details = Mage::getSingleton("eav/config" ...

  6. Train Problem II(卡特兰数+大数乘除)

    Train Problem II Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) ...

  7. android混淆打包配置(忽略第三方jar)

    在project.properties里加上   proguard.config=proguard.cfg proguard.cfg 配置如下: -optimizationpasses 5-dontu ...

  8. SpringMVC中的异步提交表单

    1.前言 近期在做一个项目,前台框架用的是EasyUI+SpringMVC,因为对SpringMVC不太了解,所以刚開始接触的时候有点吃力,在此通过一个EasyUi中的DataGrid表格来总结一下. ...

  9. 查询SQL中某表里有多少列包含某字段

    select c.name from SYSCOLUMNS as c left join SYSOBJECTS as t on c.id=t.id where c.name like '这里是某个字段 ...

  10. vs2010打开设计器出现错误

    vs2010打开设计器出现此界面,  错误多种,还有“未将对象引用设置到对象的实例”  ,我项目用到了第三方控件(没有安装,bin文件夹导入DLL文件,项目直接引用的DLL文件),看下面的堆栈信息,显 ...