标签:
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?
#include <stdio.h> int main() { int n, m; while(~scanf("%d%d", &m, &n)){ if(m==n&&n==1) printf("0\n"); else{ m = m>n?n+1:m+1; printf("%d\n", m-1); } } return 0; }
标签:
原文地址:http://www.cnblogs.com/Noevon/p/5385091.html