标签:style http io ar color os sp java for
Manao has invented a new mathematical term — a beautiful set of points. He calls a set of points on a plane beautiful if it meets the following conditions:
Consider all points (x,?y) which satisfy the inequations: 0?≤?x?≤?n; 0?≤?y?≤?m; x?+?y?>?0. Choose their subset of maximum size such that it is also a beautiful set of points.
The single line contains two space-separated integers n and m (1?≤?n,?m?≤?100).
In the first line print a single integer — the size k of the found beautiful set. In each of the next k lines print a pair of space-separated integers — the x- and y- coordinates, respectively, of a point from the set.
If there are several optimal solutions, you may print any of them.
2 2
3 0 1 1 2 2 0
4 3
4 0 3 2 1 3 0 4 2
题目分析:
要求任意两点之间的距离不是整数。换句话来说,如果两点处于同一行 或同一列 那么肯定不符合要求了。所以每一行每一列只能有一个数。其余的就随你找。我是从左下角开始,沿45°往上,直到边界为止。
自己该换个思路的。总盯着一个东西不放。教训。
代码:
标签:style http io ar color os sp java for
原文地址:http://blog.csdn.net/is_cp/article/details/41442133