Official

A - Status Code Editorial by en_translator


For beginners

This problem can be solved by coding the following procedure.

  • Receive an integer \(S\) from the Standard Input.
  • Print Success if \(S\) is between \(200\) and \(299\).
  • Print Failure otherwise.

The problem can be solved with an appropriate use of an if-else statement.

Sample code follows.

Sample code in C++

#include <iostream>

using namespace std;

int main() {
    int S;
    cin >> S;

    if (200 <= S && S <= 299) {
        cout << "Success" << endl;
    } else {
        cout << "Failure" << endl;
    }
}

Sample code in Python

S = int(input())

if 200 <= S <= 299:
    print('Success')
else:
    print('Failure')

By concatenating multiple if-else statements (or using elif in Python), each condition can be made a comparison with one integer.

Sample code in C++

#include <iostream>

using namespace std;

int main() {
    int S;
    cin >> S;

    if (S < 200) {
        cout << "Failure" << endl;
    } else if (S <= 299) {
        cout << "Success" << endl;
    } else {
        cout << "Failure" << endl;
    }
}

Sample code in Python

S = int(input())

if S < 200:
    print('Failure')
elif S <= 299:
    print('Success')
else:
    print('Failure')

posted:
last update: