CCPC-Wannafly Winter Camp Day1 (Div2) C Teardown

Category: Thinking? math?
Portal: https://www.zhixincode.com/contest/7/problem/C?problem_id=94

Ideas:

The original idea is: when A and B are relatively
prime, the answer is 1,
otherwise the answer is 2. (A bold conjecture at the time) and for A and B to be equal, all even, all odd, one odd and one even, etc. +1, -1, +2, -2, etc.), and after discussing it, I felt that it was not right and gave up.

After the explanation:
It is found that further classification and discussion can solve the problem. Used:
2 is coprime to any odd number,
3 is coprime to most even numbers, and is not coprime to a multiple of 6, it can be split into 4, if
not, it can be split into 5.
After further discussion, it is found that since they are all 2, 3, and 5, otherwise Prime numbers within 10, violence,
maybe you can

dig a hole to be filled

When making up the question, I wa many times, because I foolishly didn't notice the sentence in the question
insert image description here

AC code

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

ll gcd(ll a,ll b)
{
    return b==0?a:gcd(b,a%b);
}

int main()
{
    ll a,b;
    int t;
    cin>>t;
    while(t--)
    {
        cin>>a>>b;
        int f=0;
        if(gcd(a,b)==1)
        {
            cout<<"1"<<endl;
            cout<<a<<" "<<b<<endl;
        }
        else
        {
            for(ll i=2;i<=10;i++)
            {
                for(ll j=2;j<=10;j++)
                {
                    if(gcd(i,j)==1 && gcd(a-i,b-j)==1)
                    {
                        cout<<"2"<<endl;
                        cout<<i<<" "<<j<<endl;
                        cout<<a-i<<" "<<b-j<<endl;
                        f=1;
                        break;
                    }
                }
                if(f)break;
            }
        }
    }
    return 0;
}

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325736384&siteId=291194637