Beautiful Sets of Points

该博客探讨了一种新的数学概念——美丽点集,即坐标为整数且任意两点间距离非整数的点集。在0到n的x轴和0到m的y轴上,目标是找到这样的点的最大集合。通过考虑对角线上的点,可以避免距离为整数的情况。代码示例给出了一个解决方案,用于构造n和m约束下的最大美丽点集。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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 ≤ mx + 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.

Examples

Input

2 2

Output

3
0 1
1 2
2 0

Input

4 3

Output

4
0 3
2 1
3 0
4 2

题意:给出n,m,要求构造出最大的点的集合使得任意点对的距离不为整数。

思路:两个点在同一行或者同一列上距离就会为整数,所以考虑对角线,因为不能使用0 0,所以考虑反对角线。

#include<iostream>
#include<cstdio>
#include<map>
#include<algorithm>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<cstring>
#include<vector>
#include<set>
#include<cmath>
#include<cstring>
#include<cstdlib>
#define fi first
#define se second
#define u1 (u<<1)
#define u2 (u<<1|1)
#define PII pair<int,int>
#define ll long long
#define ull unsigned long long
#define PLL pair<long long,long long>
#define scd(a) scanf("%d",&a)
#define scdd(a,b) scanf("%d%d",&a,&b)
#define scddd(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define scl(a) scanf("%lld",&a)
#define rep(i,n) for(int i = 0; (i)<(n); i++)
#define rep1(i,n) for(int i = 1; (i)<=(n); i++)
#define pb(a) push_back(a)
#define mst(a,b) memset(a, b, sizeof a)
using namespace std;
void solve()
{
   int n,m;
   cin>>n>>m;
   cout<<min(n,m)+1<<endl;
   for(int i=n,j=0;i>=0&&j<=m;i--,j++)
   {
       cout<<i<<' '<<j<<endl;
   }
}

int main()
{
    int t=1;
   // scd(t);
    while(t--) solve();
    return 0;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值