A - Rolling Dice Editorial by en_translator


The sum of faces is at least \(A \times 1 = A\) when all of the faces are \(1\), while it is at most \(A \times 6 = 6A\) when all of them are \(6\).

Therefore, one have to check if \(B\) is between \(A\) and \(6A\), inclusive, which can be implemented with a if statement.

We will show you a sample code in C++ and Python.

  • C++
#include <iostream>
using namespace std;
 
int main() {
  int A, B;
  cin >> A >> B;
  if(A <= B && B <= 6 * A) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}
  • Python
A, B = map(int,input().split())
if A <= B <= 6 * A:
  print("Yes")
else:
  print("No")

posted:
last update: