Official

A - Supermajority Editorial by en_translator Editorial for printing


For beginners

Solution 1

Find the value \(\displaystyle B \times \frac{2}{3}\) as a floating-point number, and compare it with \(A\) to find the answer.

Sample code (Python):

a, b = map(int, input().split())

if (a > b*2/3):
  print("Yes")
else:
  print("No")

Sample code (C++):

#include <iostream>
using std::cin;
using std::cout;
using std::cerr;
using std::endl;

int main (void) {
	int a, b;
	cin >> a >> b;

	if ((double)a > (double)b * 2 / 3) {
		cout << "Yes" << "\n";
	} else {
		cout << "No" << "\n";
	}

	return 0;
}

Solution 2

Multiply the both sides of \(\displaystyle A > B \times \frac{2}{3}\) by \(3\) to obtain an equivalent inequality \(A \times 3 > B \times 2\). This allows to find the answer without relying on floating-point numbers but only on integers.

Sample code (Python):

a, b = map(int, input().split())

if (a*3 > b*2):
  print("Yes")
else:
  print("No")

Sample code (C++):

#include <iostream>
using std::cin;
using std::cout;
using std::cerr;
using std::endl;

int main (void) {
	int a, b;
	cin >> a >> b;

	if (3 * a > 2 * b) {
		cout << "Yes" << "\n";
	} else {
		cout << "No" << "\n";
	}

	return 0;
}

Bonus

Since \(A\) is an integer, \(\displaystyle A > B \times \frac{2}{3}\) is equivalent to \(\displaystyle A > \lfloor \frac{2B}{3} \rfloor\). Therefore, directly evaluating the expression in the problem using floor division also yields a correct answer.

  • Find an example of \((A,B)\) such that \(\displaystyle A = B \times \frac{2}{3}\) is violated, but \(\displaystyle A = \lfloor \frac{2B}{3} \rfloor\) is satisfied.
  • Find an example of \((A,B)\) such that \(\displaystyle A < B \times \frac{2}{3}\) is satisfied, but \(\displaystyle A < \lfloor \frac{2B}{3} \rfloor\) is violated.
  • Do such examples exist even if the first and second inequalities are swapped?

posted:
last update: