Number Game
Gordon is recently reading about an interesting game. At the beginning of the game, there are three positive numbers written on a blackboard. In each round, you are asked to delete one of these three numbers. And you should write the sum of the remaining two numbers minus one back to the blackboard. For example, there are three numbers, 2, 3 and 10 on the blackboard. If you decide to change the number 3 in this round, you will delete the number 3 first and put the number 11=2+10-1 back to the blackboard. So it would be 2, 10 and 11 on the blackboard then. The target of this game is to reach a given number in the minimal steps.
One day, when Gordon was playing the game, his best friend Mike came in. Mike saw that the numbers on the blackboard were 17, 1967 and 1983, and asked Gordon if he had played this game from the beginning numbers 3, 3 and 3. Since Gordon didn’t leave a trace on the game, he asked you, a young brilliant programmer, to help them check out if Mike made the right guess.

Input

Each test case consists of a line with six positive integers. The first three are the numbers currently on Gordon’s blackboard and the last three are the numbers that Mike guessed. It is guaranteed that every number in a game is positive and is less than 1,000,000.

Output

For each test case, you should write a single word in a line. If it is possible to get Gordon’s numbers from Mike’s guess, you would give the word “Yes”. Otherwise you need to output the word “No”.

Sample Input

2
6 10 15 7 13 26
17 1967 1983 3 3 3

Sample Output

No
Yes

如果是的话,最大的那个数一定是另外两个数之差加1变来的,循环操作,直到最大的数不是其他两个数的和-1,注意最后可能不再变化

#include<bits/stdc++.h>
using namespace std;
int a[3],b[3],ans[3][3];
bool judge(int x[],int y[])
{
   
    int flag=1;
    for(int i=0; i<3; i++)
    {
   
        if(x[i]!=y[i])
        {
   
            flag=0;
            break;
        }
    }
    return flag;
}
void copyy(int x[],int y[])
{
   
    for(int i=0;i<3;i++)
        x[i]=y[i];
}
int main()
{
   
    int tmp[3],i,j,n,m,t;
    scanf("%d",&t);
    while(t--)
    {
   
        scanf("%d%d%d%d%d%d",&a[0],&a[1],&a[2],&b[0],&b[1],&b[2]);
        sort(a,a+3);
        sort(b,b+3);
        ans[0][0]=b[0];
        ans[0][1]=b[1];
        ans[0][2]=b[1]+b[0]-1;
        sort(ans[0],ans[0]+3);
        ans[1][0]=b[0];
        ans[1][1]=b[2];
        ans[1][2]=b[2]+b[0]-1;
        sort(ans[1],ans[1]+3);
        ans[2][0]=b[1];
        ans[2][1]=b[2];
        ans[2][2]=b[1]+b[2]-1;
        sort(ans[2],ans[2]+3);
        copyy(tmp,a);
        int f=0;
        while(1)
        {
   
            if(judge(a,ans[0])||judge(a,ans[1])||judge(a,ans[2]))
            {
   
                f=1;
                cout<<"Yes"<<'\n';
                break;
            }
            if(a[2]+1!=a[0]+a[1])
                break;
            a[2]=a[1]+1-a[0];
            sort(a,a+3);
            if(judge(tmp,a))
                break;
            copyy(tmp,a);
        }
        if(!f)
        {
   
            if(judge(a,ans[0])||judge(a,ans[1])||judge(a,ans[2]))
                cout<<"Yes"<<'\n';
            else
                cout<<"No"<<'\n';
        }
    }
    return 0;
}