题目链接:点击打开题目
10101
01010
10101
举个例子,上面的把第二行0翻转,再把第2、4列翻转就完成了任务,所以公式很好看出来。
代码如下:
#include <cstdio>
#include <iostream>
using namespace std;
int main()
{
int u,h,w;
cin >> u;
while (u--)
{
cin >> h >> w;
int ans = (h >> 1) + (w >> 1);
cout << ans << endl;
}
return 0;
}