题解
ab两个数字如果互质直接输出a和b 如果不互质则在10以内暴力就可以得到答案 为什么是这样我也不清楚哈哈 当作一个结论记了
AC代码
#include <stdio.h>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
ll gcd(ll a, ll b)
{
if (!b) return a;
return gcd(b, a % b);
}
void solve(ll a, ll b)
{
if (gcd(a, b) == 1)
{
printf("1\n%lld %lld\n", a, b);
return;
}
for (int i = 2; i <= 10; i++) //小范围暴力
for (int j = 2; j <= 10; j++)
if (gcd(i, j) == 1 && gcd(a - i, b - j) == 1)
{
printf("2\n%d %d\n", i, j);
printf("%lld %lld\n", a - i, b - j);
return;
}
}
int main()
{
#ifdef LOCAL
freopen("C:/input.txt", "r", stdin);
#endif
int T;
cin >> T;
while (T--)
{
ll a, b;
scanf("%lld%lld", &a, &b);
solve(a, b);
}
return 0;
}