Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

coinPiles

#include<bits/stdc++.h>
using namespace std; 
#define int int64_t
#define pb push_back
#define f(a,b) 
for(int i=a; i<b; i++) 
signed main(){    
  int t; cin>>t;    
  int a, b;    
  while(t--)    
  {        
    cin>>a>>b;        
    while(true)        
    {            
      a>b ? a-=2, b-- : b -= 2,a--;            
      if(a==0 || b==0) break;        
    }        
    if(a==0 && b==0) { cout<<"YES
"; continue; }        
    if(a==0 && b!=0) { cout<<"NO
"; continue; }        
    if(a!=0 || b==0) { cout<<"NO
"; continue; }    
  }    
  return 0;
}
Source by cses.fi #
 
PREVIOUS NEXT
Tagged: #coinPiles
ADD COMMENT
Topic
Name
4+8 =