码迷,mamicode.com
首页 > 其他好文 > 详细

codeforces 268C

时间:2014-11-24 11:52:56      阅读:263      评论:0      收藏:0      [点我收藏+]

标签: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:

  1. The coordinates of each point in the set are integers.
  2. 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.

Input

The single line contains two space-separated integers n and m (1?≤?n,?m?≤?100).

Output

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.

Sample test(s)
input
2 2
output
3
0 1
1 2
2 0
input
4 3
output
4
0 3
2 1
3 0
4 2
题目分析:
要求任意两点之间的距离不是整数。换句话来说,如果两点处于同一行 或同一列 那么肯定不符合要求了。所以每一行每一列只能有一个数。其余的就随你找。我是从左下角开始,沿45°往上,直到边界为止。
自己该换个思路的。总盯着一个东西不放。教训。
代码:
 

codeforces 268C

标签:style   http   io   ar   color   os   sp   java   for   

原文地址:http://blog.csdn.net/is_cp/article/details/41442133

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!