公式

A - Christmas Present 解説 by en_translator


If you are new to learning programming and do not know where to start, please try Problem A “Welcome to AtCoder” from practice contest. There you can find a sample code for each language.
Also, if you are not familiar with problems in programming contests, we recommend you to try some problems in “AtCoder Beginners Selection” (https://atcoder.jp/contests/abs).


This problem asks to implement input, output, and a simple conditional branch. Receive the two integers as input, compare them, and print the string according to the result.

For more details on implementation, please refer to the following sample code (C++ and Python). It is convenient to use a ternary operator to express such a simple conditional branch.

Sample code (C++):

#include<bits/stdc++.h>

using namespace std;

int main() {
    int b, g;
    cin >> b >> g;
    cout << (b > g ? "Bat" : "Glove") << endl;
}

Sample code (Python) :

b, g = map(int, input().split())
print("Bat" if b > g else "Glove");

投稿日時:
最終更新: