coin_piles.cpp (561B)
1 #include <bits/stdc++.h> 2 3 using namespace std; 4 5 using ui = unsigned int; 6 using l = long; 7 using ul = unsigned long; 8 using ll = long long; 9 using ull = unsigned long long; 10 11 using vi = vector<int>; 12 using vui = vector<ui>; 13 using vl = vector<l>; 14 using vul = vector<ul>; 15 using vll = vector<ll>; 16 using vull = vector<ull>; 17 18 void solve() 19 { 20 int a, b; 21 cin >> a >> b; 22 int x = 2 * a - b; 23 int y = 2 * b - a; 24 if (x >= 0 && y >= 0 && x % 3 == 0 && y % 3 == 0) 25 cout << "YES\n"; 26 else 27 cout << "NO\n"; 28 return; 29 } 30 31 int main() 32 { 33 int t; 34 cin >> t; 35 while (t--) 36 solve(); 37 }