Searching for Nessy
来源:互联网 发布:淘宝怎么运营推广 编辑:程序博客网 时间:2024/06/05 05:47
Searching for Nessy
he Loch Ness Monsteris a mysterious and unidenti ed animal said to inhabit Loch Ness, a large deep
freshwater loch near the city of Inverness in northern Scotland. Nessie is usually categorized as a type
of lake monster.
http://en.wikipedia.org/wiki/Loch
Ness
Monster
In July 2003, the BBC reported an extensive investiga-
tion of Loch Ness by a BBC team, using 600 separate sonar
beams, found no trace of any \sea monster" (i.e., any large
animal, known or unknown) in the loch. The BBC team con-
cluded that Nessie does not exist. Now we want to repeat the
experiment.
Given a grid of
n
rows and
m
columns representing the
loch, 6
n
,
m
10000, nd the minimum number
s
of sonar
beams you must put in the square such that we can control
every position in the grid, with the following conditions:
•
one sonar occupies one position in the grid; the sonar
beam controls its own cell and the contiguous cells;
•
the border cells do not need to be controlled, because
Nessy cannot hide there (she is too big).
For example,
where
X
represents a sonar, and the shaded cells are controlled by their sonar beams; the last gure
gives us a solution.
Input
The rst line of the input contains an integer,
t
, indicating the number of test cases. For each test case,
there is a line with two numbers separated by blanks, 6
n
,
m
10000, that is, the size of the grid (
n
rows and
m
columns).
Output
For each test case, the output should consist of one line showing the minimum number of sonars that
veri es the conditions above.
SampleInput
3
6 6
7 7
9 13
SampleOutput
4
4
12
大意:
一个声呐可以探测一个3*3的方格,给出m*n的方格,求出最少用多少个声呐可以全部探测完;
边缘地带不用探测;
代码:
#include <stdio.h>int main(){int num;scanf ("%d", &num);getchar();while (num--){int m, n;scanf ("%d %d", &m, &n);getchar();m = m / 3;n = n / 3;printf("%d\n", m * n);}return 0;}
0 0
- 11044 - Searching for Nessy
- 11044 - Searching for Nessy
- 11044 - Searching for Nessy
- UVA11044 - Searching for Nessy
- Searching for Nessy
- Searching for Nessy
- 11044 - Searching for Nessy
- UVA11044 Searching for Nessy
- uva11044 Searching for Nessy
- Searching for Nessy
- UVa 11044 - Searching for Nessy
- uva 11044 Searching for Nessy
- uva 11044 - Searching for Nessy
- uva-11044 - Searching for Nessy
- UVa 11044 - Searching for Nessy
- UVa 11044 - Searching for Nessy
- UVa 11044 - Searching for Nessy
- UVA 11044 Searching for Nessy
- 华为是怎样研发的(4)——器件选型
- HDOJ 5298 Solid Geometry Homework
- System类的学习
- Eclipse(MyEclipse) 自动补全
- 华为是怎样研发的(3)——专题分析
- Searching for Nessy
- hdu 5336 XYZ and Drops 2015 Multi-University Training Contest 4 10
- leetcode 91:Decode Ways
- 关于javaIDE开发环境JDK,java compiler的问题
- (一) 初识HTTP/2
- 设计模式--工厂模式
- android design library提供的TabLayout的用法
- 浅析绑定远程服务bindService基本原理与AIDL分析
- 数论、、gcd