题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2177
思路:模板题,暴力找出怎么取就行。
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cctype>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <sstream>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll inff = 0x3f3f3f3f3f3f3f3f;
#define FOR(i,a,b) for(int i(a);i<=(b);++i)
#define FOL(i,a,b) for(int i(a);i>=(b);--i)
#define REW(a,b) memset(a,b,sizeof(a))
#define inf int(0x3f3f3f3f)
#define si(a) scanf("%d",&a)
#define sl(a) scanf("%I64d",&a)
#define sd(a) scanf("%lf",&a)
#define ss(a) scanf("%s",a)
#define mod int(1e9+7)
#define lc (d<<1)
#define rc (d<<1|1)
#define P pair<int,int>
#define pi acos(-1)
void as(int n,int m)
{
if(n<m) swap(n,m);
int k=n-m;
if((int)(k*(1+sqrt(5))/2.0)==m)
{
cout<<0<<endl;
return;
}
else
{
cout<<1<<endl;
int a,b;
FOR(i,1,m)
{
a=n-i;
b=m-i;
k=a-b;
if(b==(int)(k*(1+sqrt(5))/2.0))
{
cout<<b<<" "<<a<<endl;
break;
}
}
FOL(i,n-1,0)
{
b=i;
a=m;
if(a<b) swap(a,b);
k=a-b;
if(b==(int)(k*(1+sqrt(5))/2.0))
{
cout<<b<<" "<<a<<endl;
}
}
}
}
int main()
{
cin.tie(0);
int a,b;
while(scanf("%d %d",&a,&b)!=EOF&&(a+b))
{
as(a,b);
}
return 0;
}