Official

A - New Generation ABC Editorial by en_translator


It can be implemented with a if statement.

Sample code (C++) :

#include <bits/stdc++.h>
using namespace std;

int main() {
  int N;
  cin >> N;
  if (N <= 125) {
    cout << 4 << '\n';
  } else if (N <= 211) {
    cout << 6 << '\n';
  } else {
    cout << 8 << '\n';
  }
  return 0;
}

Note that the code can be shortened by using a ternary operator.

Sample code (C++) :

#include <bits/stdc++.h>
using namespace std;

int main() {
  int N;
  cin >> N;
  cout << (N <= 125 ? 4 : (N <= 211 ? 6 : 8)) << '\n';
  return 0;
}

Sample code (Python) :

n = int(input())
print(4 if n <= 125 else 6 if n <= 211 else 8)

posted:
last update: