公式
A - Penalty Kick 解説 by en_translator
For beginners
- 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".
- 「C++入門 AtCoder Programming Guide for beginners (APG4b)」 is a C++ tutorial for competitive programmers. Sadly, this is only in Japanese too.
In this problem, you are asked to implement input, output, loop operation using the for
statement, arithmetic operations, and handling strings.
This problem can be solved by, for example, first preparing an empty string, scan the \(1\)-th through \(N\)-th kick, and appending o
if it succeeds or x
if it fails. For the details of implementation, please refer to the sample code below.
Sample code (C++):
#include <bits/stdc++.h>
using namespace std;
int main() {
int N;
cin >> N;
string S = "";
for (int i = 1; i <= N; ++i) {
if (i % 3 == 0) S += 'x';
else S += 'o';
}
cout << S << endl;
}
Sample code (Python):
N = int(input())
S = ""
for i in range(1,N+1):
if i%3 == 0:
S += "x"
else:
S += "o"
print(S)
投稿日時:
最終更新: