cses

My solution for the coding challenges of cses.fi
git clone https://git.tronto.net/cses
Download | Log | Files | Refs | README

coin_piles_1754.cpp (328B)


      1 #include <algorithm>
      2 #include <iostream>
      3 
      4 bool f(int a, int b) {
      5 	auto max = std::max(a, b);
      6 	auto min = std::min(a, b);
      7 
      8 	return max <= 2*min && (2*min - max) % 3 == 0;
      9 }
     10 
     11 int main() {
     12 	int t, a, b;
     13 	std::cin >> t;
     14 	for (int i = 0; i < t; i++) {
     15 		std::cin >> a >> b;
     16 		std::cout << (f(a, b) ? "YES" : "NO") << std::endl;
     17 	}
     18 }