A. Anti Light‘s Cell Guessing
You are playing a game on a n×mn×m grid, in which the computer has selected some cell (x,y)(x,y) of the grid, and you have to determine which one.
To do so, you will choose some kk and some kk cells (x1,y1),(x2,y2),…,(xk,yk)(x1,y1),(x2,y2),…,(xk,yk), and give them to the computer. In response, you will get kk numbers b1,b2,…bkb1,b2,…bk, where bibi is the manhattan distance from (xi,yi)(xi,yi) to the hidden cell (x,y)(x,y) (so you know which distance corresponds to which of kk input cells).
After receiving these b1,b2,…,bkb1,b2,…,bk, you have to be able to determine the hidden cell. What is the smallest kk for which is it possible to always guess the hidden cell correctly, no matter what cell computer chooses?
As a reminder, the manhattan distance between cells (a1,b1)(a1,b1) and (a2,b2)(a2,b2) is equal to |a1−a2|+|b1−b2||a1−a2|+|b1−b2|.
Input
The first line of the input contains a single integer tt (1≤t≤1041≤t≤104) — the number of test cases. The description of test cases follows.
The single line of each test case contains two integers nn and mm (1≤n,m≤1091≤n,m≤109) — the number of rows and the number of columns in the grid.
Output
For each test case print a single integer — the minimum kk for that test case.
Example
input
Copy
2 2 3 3 1
output
Copy
2 1
思路:本题大意是一个点可以最少通过到几个点的曼哈顿距离确定这个点(如下图)
n=1&&m=1时不需要其他点,n=1 || m = 1时需要一个点
其他情况只需要两个点
#include<iostream>
#include<cstring>
#include<algorithm>using namespace std;const int N = 1e9 + 10;
int t, n, m;int main()
{cin >> t;while(t --){cin >> n >> m;if(n == 1 && m == 1) cout <<"0" << endl;else if (n == 1 || m == 1) cout << "1" << endl;else cout << "2" << endl;}return 0;
}
(萌新上路,有更好的方法或者写的有问题可以多多交流)
A. Anti Light‘s Cell Guessing相关推荐
- Light OJ - 1008 - Fibsieve`s Fantabulous Birthday 题解
就是计算特殊长方形坐标的问题,这类题目需要的是细心,细心,再细心,然后推导摸索出公式来, 题目如下: Fibsieve had a fantabulous (yes, it's an actual w ...
- 如何正确清理Excel互操作对象?
我在C#( ApplicationClass )中使用Excel互操作,并将以下代码放在我的finally子句中: while (System.Runtime.InteropServices.Mars ...
- 大一集训题i题生日聚会lightoj-1008 - Fibsieve`s Fantabulous Birthday
大一集训题i题生日聚会lightoj-1008 - Fibsieve`s Fantabulous Birthday **大一集训题i题生日聚会lightoj-1008 - Fibsieves Fant ...
- Cell子刊:16s分析之FishTaco分析
一次偶然的机会我看到了这篇文章,发表于Cell Host & Microbe上,这个期刊也不怎么熟悉,偏机理,就点了WOS上的期刊信息: Systematic Characterization ...
- 2019年上半年国内学者在植物领域共发表6篇Science, 1篇Nature,1篇Cell!
iPlants,专注植物最前沿.更多前沿研究,请关注我们! iPlants: 截止2019年6月23日,以国内学者为通讯作者的CNS文章,总共发表了8篇,分别为1篇Nature, 6篇Science, ...
- 复现Cell附图 |类器官的单细胞分析
类器官的单细胞分析 NGS系列文章包括NGS基础.转录组分析 (Nature重磅综述|关于RNA-seq你想知道的全在这).ChIP-seq分析 (ChIP-seq基本分析流程).单细胞测序分析 (重 ...
- LPV(Light Propagation Volumes)
lpv 测试了Light Propagation Volumes,全实时没有任何预处理的GI,而且可以适用任意场景. 文档很长,不过基本原理还是比较直白的: 生成reflect shad ...
- 【Paper】WISDM:Activity Recognition using Cell Phone Accelerometers
论文原文:点击此处 论文下载:点击此处 论文被引:2034 论文年份:2010 本文是WISDM (WIreless Sensor Data Mining) 无线传感数据挖掘实验室的第一篇论文. 如果 ...
- RFP红色荧光蛋白抗体——Nature、Cell高分文章
RFP / DsRed作为分子探针可以实现对活细胞,细胞器或胞内分子的时空标记和追踪,已经在生物工程学.细胞生物学.基础医学领域得到广泛应用. Rockland 艾美捷 RFP红色荧光蛋白抗体除了做W ...
最新文章
- GlusterFS的安装及使用
- 区块链教程Fabric1.0源代码gRPC(Fabric中注册的gRPC Service)一
- Tensorflow安装后,import时出现错误:ImportError: DLL load failed: 找不到指定的模块
- 框架开发之Java注解的妙用
- Halcon基础知识:常规数据、对象数据、对象元组
- 语言代码编程大赛简讯_精品干货:C语言的高效编程与代码优化
- include php 失效,为什么include(‘php:// input’)不起作用?
- 灯泡四个闪烁c语言程序设计教程课后答案,c语言编程题及答案4.doc
- php 随机在文章中添加锚文本_页面SEO优化的锚文本优化概念
- MySql 主从模式原理及操作步骤
- 欢迎大家制作搜狗输入法flash皮肤。
- c语言 程序设计 题库答案 p,c语言 程序设计 题库答案 p
- 腾讯云海外音视频技术架构 — 挑战和优化
- 不同网段怎么ping通
- 图灵奖得主都写过哪些书?
- linux 切换ked桌面,manjaro更换桌面环境
- 历史上最“好”的皇帝--宋仁宗
- day---06 文件的操作
- 会议记录怎样做得又快又好?一分钟学会录音转文字
- java基础之Object类_繁星漫天_新浪博客