公式

A - Long Loong 解説 by en_translator


Just as instructed in the problem statement, print one L, \(N\) copies of o, one n, and one g in this order.
This can be done through standard output using a for statement.
There are two approach depending on whether to print them one by one, or first construct the string and then print it. Both of them require almost the same amount of implementation, so this time either is OK.

Be careful not to include an excessive newline at the end of the output.

Sample code in C++

#include <bits/stdc++.h>
using namespace std;

int main() {
	int n;
	cin>>n;
	string s="L";
	for(int i=0;i<n;i++)s+="o";
	s+="ng";
	cout<<s<<endl;
	return 0;
}

Sample code in Python

n=int(input())
print("L",end='')
for i in range(n):
    print("o",end='')
print("ng")

投稿日時:
最終更新: