#include <stdio.h>
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
 
typedef struct node
{
    int A;
    int B;
    int C;    
}node;
 
int A, B, C;
bool flag = false;
 
queue<node> q;
set<pair<pair<intint>int>> visited;
 
void BFS()
{
    visited.insert({{A, B}, C});
    q.push({A, B, C});
    
    while(!q.empty())
    {
        int A = q.front().A;
        int B = q.front().B;
        int C = q.front().C;
        q.pop();
        
        if(A == B && B == C)
        {
            flag = true;
            return;
        }
        
        // 3C2 = 3
        for(int i = 1; i <= 3; i++)
        {
            // A-B
            if(i == 1)
            {
                if(A > B)
                {
                    if(visited.find({{A-B, B+B}, C}) == visited.end())
                    {
                        visited.insert({{A-B, B+B}, C});    
                        q.push({A-B, B+B, C});    
                    }
                }
                else
                {
                    if(visited.find({{A+A, B-A}, C}) == visited.end())
                    {
                        visited.insert({{A+A, B-A}, C});    
                        q.push({A+A, B-A, C});    
                    }
                }
            }
            // B-C
            else if(i == 2)
            {
                if(B > C)
                {
                    if(visited.find({{A, B-C}, C+C}) == visited.end())
                    {
                        visited.insert({{A, B-C}, C+C});    
                        q.push({A, B-C, C+C});    
                    }
                }
                else
                {
                    if(visited.find({{A, B+B}, C-B}) == visited.end())
                    {
                        visited.insert({{A, B+B}, C-B});
                        q.push({A, B+B, C-B});    
                    }
                }
            }
            // A-C
            else if(i == 3)
            {
                if(A > C)
                {
                    if(visited.find({{A-C, B}, C+C}) == visited.end())
                    {
                        visited.insert({{A-C, B}, C+C});
                        q.push({A-C, B, C+C});    
                    }
                }
                else
                {
                    if(visited.find({{A+A, B}, C-A}) == visited.end())
                    {
                        visited.insert({{A+A, B}, C-A});    
                        q.push({A+A, B, C-A});    
                    }
                }
            }    
        }
    }
}
 
int main(void)
{
//    freopen("B12886_input.txt", "r", stdin);
    
    scanf("%d %d %d"&A, &B, &C);
    
    BFS();
    
    if(flag == true)
    {
        printf("1");
    }
    else
    {
        printf("0");
    }
        
    return 0;
}
cs

+ Recent posts