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. MVC in Javascript

    MVC in Javascript From http://www.cnblogs.com/tugenhua0707/p/5156179.html 原博的比我详细 我是以自己的惯用的方式实现了一下 M ...

  2. SQL Server 数据库的自动选项

    自动选项影响SQL Server 可能会自动进行的操作,所有的这些都是bool值,值为on 或off 1. auto_close: 当这个为on 时.数据库在最后一个用户退出后完全关闭,这样数据库就不 ...

  3. undo_retention:确定最优的撤销保留时间

    使用下面的公式来计算undo_retention参数的值: undo_retention=undo size/(db_block_size * undo_block_per_sec) 可以通过提交下面 ...

  4. Oracle EBS-SQL (BOM-12):BOM清单查询

    select     msi.segment1                    装配件编码    ,msi.description                  装配件描述    ,msi. ...

  5. Delphi 实现任务栏多窗口图标显示

    uses Windows; type TfrmLogin = class(TForm) end; implementation {$R *.dfm} procedure TfrmLogin.FormC ...

  6. Oracle检查与安装操作内容

    Oracle 安装: 检查安装包 rpm -q binutils compat-libstdc++ elfutils-libelf elfutils-libelf-devel elfutils-lib ...

  7. Linux学习十八之、善用判断式

    原文地址:http://vbird.dic.ksu.edu.tw/linux_basic/0340bashshell-scripts_3.php 善用判断式 在第十一章中,我们提到过 $? 这个变量所 ...

  8. 解决itunesconnect无法訪问

    今天打开https://itunesconnect.apple.com出现了无法訪问提示,例如以下图, 我起初以为苹果在维护呢,但想想,假设是维护提示页面也应该会友好些.带着疑问,google一搜,看 ...

  9. asp.net 超链接 下载TEXT文件,而不是直接在IE中打开

    问题描述:后台生成了文本文件,用超链接提供给用户下载.点击超链接,下载Excel文件没问题,但文本文件会直接被打开,而不是弹出下载窗口. 解决方法:把HyperLink改为LinkButton,在Cl ...

  10. asp.net验证控件中常用的正则表达式

    只能输入数字:“^[0-9]*$” 只能输入n位的数字:“^\d{n}$” 只能输入至少n位数字:“^\d{n,}$” 只能输入m-n位的数字:“^\d{m,n}$” 只能输入零和非零开头的数字:“^ ...