Whu oj 1606 - Funny Sheep
来源:互联网 发布:网络注册表修复win7 编辑:程序博客网 时间:2024/05/21 05:20
Problem 1606 - Funny Sheep
Time Limit: 1000MS Memory Limit: 65536KB
Total Submit: 605 Accepted: 165 Special Judge: No
Total Submit: 605 Accepted: 165 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
可以拆除最外围的栅栏。
#include<cstdio> #include<cstring> int main() { int n,m,ans; while(scanf("%d%d",&n,&m)!=EOF) { if(n>=m) ans=m; if(m>n) ans=n; if(ans>(n-1+m-1)) ans=n-1+m-1; printf("%d\n",ans); } return 0; }
0 0
- Whu oj 1606 - Funny Sheep
- Land oj 1606 - Funny Sheep(技巧&规律)
- Problem 1606 - Funny Sheep
- WHOJ 1606 - Funny Sheep【水】
- lanoj--1606--Funny Sheep(规律水题)
- whu oj 1579 - Big data
- Whu oj 1609 - Han Move
- Whu oj 1604 - Play Apple
- Whu oj Problem 1603 - Minimum Sum
- AOJ-AHU-OJ-31 Counting Sheep
- whu oj 1551 Pairs (莫队算法)
- [AC自动机+dp] whu oj 1572 I - Cyy and Fzz
- funny
- funny
- funny
- funny
- funny
- funny
- OpenStack 性能测试Rally
- 我的Android的入门第一天
- Deep learning tutorial
- Linux安装模式下, 磁盘分区的选择(极重要)
- tomcat(3)连接器
- Whu oj 1606 - Funny Sheep
- 毕业5年总结
- JavaScript编写人机对战五子棋(七)
- POJ 2987 Firing 最小割(最大权闭合子图)
- Collection集合层次结构图
- 认识 EXT2 文件系统、磁盘分区 ( Partition )、文件系统:
- mysql索引
- leetcode 58. Length of Last Word
- 更新到Xcode 7.3 #import 不提示的问题