lanoj--1606--Funny Sheep(规律水题)
来源:互联网 发布:重庆seo服务 编辑:程序博客网 时间:2024/06/10 19:18
Problem 1606 - Funny Sheep
Time Limit: 1000MS Memory Limit: 65536KB
Total Submit: 613 Accepted: 169 Special Judge: No
Total Submit: 613 Accepted: 169 Special Judge: No
Description
There are N+1 rows and M+1 columns fence with N*M grids on the grassland. Each grid has a sheep. In order to let the sheep together, we need to dismantle the fence. Every time you can remove a row or a column of fences. What’s the least number of times to reach the goal?
Input
There are multiple test cases.
The first line of each case contains two integers N and M. (1≤N,M≤1000)
The first line of each case contains two integers N and M. (1≤N,M≤1000)
Output
For each case, output the answer in a line.
Sample Input
1 2
2 2
2 2
Sample Output
1
2
2
题意:m行n列的网格由篱笆围成,每个格子中都有一个一只羊,每次可以选择拆除一行或者一列的篱笆,最后要使得所有的羊可以跑到一起
刚开始傻了,其实很简单,拆除m行或者n列再或者n+m-2行和列,取三者的最小值,说是让他们可以跑到一起,但是并没有说必须要全部锁在一个格子,所以他们可以通过外部跑到一起
#include<cstdio>#include<queue>#include<algorithm>using namespace std;int main(){int n,m;while(scanf("%d%d",&n,&m)!=EOF){printf("%d\n",min(n,min(m,m+n-2)));}return 0;}
0 0
- lanoj--1606--Funny Sheep(规律水题)
- Land oj 1606 - Funny Sheep(技巧&规律)
- WHOJ 1606 - Funny Sheep【水】
- Problem 1606 - Funny Sheep
- Whu oj 1606 - Funny Sheep
- POJ 2484 A Funny Game(规律)
- HDU 6050 Funny Function (规律+逆元)
- POJ 2484 A Funny Game(规律直推)
- HDU 6016 Count the Sheep(思维水题)
- POJ 2484 A Funny Game(找规律)
- hdu2952(Counting Sheep )
- Counting Sheep(HDU2952)
- HDU 6016 Count the Sheep(思维题)(Interesting)
- 【POJ 2484】A Funny Game 博弈找规律
- 博弈,找规律_______A Funny Game(poj 2484)
- hdu6050 Funny Function【打表+找规律+矩阵快速幂】
- funny
- funny
- Linux基础知识
- 这些小工具让你的Android 开发更高效
- 动态分配内存的函数在两个库函数中
- plsql问题备忘
- opencl:C++11下使用别名(x,y,z,hi,lo...)访问vector类型(cl_int2,cl_long16...)的元素
- lanoj--1606--Funny Sheep(规律水题)
- S5PV210中断处理的编程实践1~2
- 滑动条
- C语言字符串转换为oc
- 【剑指offer系列】 复杂链表的复制___26
- jdk1.6容器-LinkedList源码
- Mybatis分页
- 线程饥饿死锁
- Splash闪屏页的使用方法