Official

A - Anyway Takahashi Editorial by en_translator


This problem is aimed at learning Standard Input and Output that is indispensable for enjoying AtCoder.
Standard Input and Standard Output is the “standard” input and output, that is, those that a program can use when it is executed without specified source of input and destination of output. In an ordinary system, Standard Input corresponds to the user’s key input through the keyboard, and Standard Output to outputting to the display.
In competitive programming, you interact the data between the judge and program using Standard Input and Output, so you need to understand how to use Standard Input and Output when solving a problem.

In C++, for example, one can use cin and cout and input/output operators >> and << to receive the input from Standard Input and to print to Standard Output.

int x;
// Receive an integer
cin >> x; 
// Print the integer and a newline
cout << x << endl; 

The following is a sample code in Python3 (PyPy3). (For other languages, see the References section in practice contest A: Welcome to AtCoder.)

  • C++
#include <iostream>
using namespace std;

int main() {
  // Receive integers separated by spaces
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int answer = (a + b) * (c - d);
  // Print an integer
  cout << answer << endl;
  // Print a string
  cout << "Takahashi" << endl;
}
  • Python3(PyPy3)
# Receive integers separated by spaces
a, b, c, d = map(int, input().split())
answer = (a + b) * (c - d)
# Print an integer
print(answer)
# Print a string
print("Takahashi")

posted:
last update: