首页 > 代码库 > codeforces 268C
codeforces 268C
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:
- The coordinates of each point in the set are integers.
- For any two points from the set, the distance between them is a non-integer.
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
30 11 22 0
4 3
40 32 13 04 2
题目分析:
要求任意两点之间的距离不是整数。换句话来说,如果两点处于同一行 或同一列 那么肯定不符合要求了。所以每一行每一列只能有一个数。其余的就随你找。我是从左下角开始,沿45°往上,直到边界为止。
自己该换个思路的。总盯着一个东西不放。教训。
代码:
<script src="https://code.csdn.net/snippets/530535.js" type="text/javascript"></script>
codeforces 268C