Official

A - Edge Checker Editorial by en_translator


The points numbered \(a\) and \(b\) are directly connected with a line segment if and only if \(b-a = 1\) or \(b-a = 9\).
Therefore, we can make the following program to get accepted for this problem.

  1. First, read \(a\) and \(b\) from the Standard Input.
  2. Next, check if \(b-a = 1\) or \(b-a=9\) holds.
    • If it holds, output Yes to the Standard Output.
    • If it doesn’t, output No to the Standard Output.

Inputting and outputting can be achieved in different ways in different languages, so check the specification of the language you use.
In order to “check if \(b-a = 1\) or \(b-a=9\) holds,” you can use the conditional branch (like if statement), which is a standard feature of programming languages.

The following is a sample code in C++.

#include <iostream>
using namespace std;

int main(void)
{
  int a, b;
  cin >> a >> b;
  
  if(b-a == 1 || b-a == 9) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}

posted:
last update: