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.
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;
}