A - Nine Editorial by evima

Another Solution by Proposer

There is also a down-to-earth approach that finds which row and column contain the squares marked with \(A\) and \(B\). The quotient and remainder when \(A - 1\) is divided by \(3\) correspond to the row and column where \(A\) is written, respectively (here, the topmost row will be the \(0\)-th row, and the leftmost column will be the \(0\)-th column).

Sample Implementation (Python)

A, B = map(int, input().split())
ra, ca = (A - 1) // 3, (A - 1) % 3
rb, cb = (B - 1) // 3, (B - 1) % 3
print('Yes' if ra == rb and ca + 1 == cb else 'No')

posted:
last update: