-
Notifications
You must be signed in to change notification settings - Fork 0
/
A.cpp
40 lines (39 loc) · 1.04 KB
/
A.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include<bits/stdc++.h>
#include<string>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
int main()
{
fastio;
long long t,a,b;
cin>>t;
while(t--)
{
cin>>a>>b;
if(__gcd(a,b)==1)
{
cout<<1<<"\n";
cout<<a<<" "<<b<<"\n";
}
else
{
cout<<2<<"\n";
if(a-1>=0 && b-1>=0 && __gcd(a-1,b-1)==1)
cout<<a-1<<" "<<b-1<<"\n";
else if(a-1>=0 && __gcd(a-1,b)==1)
cout<<a-1<<" "<<b<<"\n";
else if(a-1>=0 && __gcd(a-1,b+1)==1)
cout<<a-1<<" "<<b+1<<"\n";
else if(b-1>=0 && __gcd(a,b-1)==1)
cout<<a<<" "<<b-1<<"\n";
else if(__gcd(a,b+1)==1)
cout<<a<<" "<<b+1<<"\n";
else if(b-1>=0 && __gcd(a+1,b-1)==1)
cout<<a+1<<" "<<b-1<<"\n";
else if(__gcd(a+1,b+1)==1)
cout<<a+1<<" "<<b+1<<"\n";
cout<<a<<" "<<b<<"\n";
}
}
return 0;
}