公式

A - Handmaid 解説 by en_translator


For beginners

Implementation approach

It is sufficient to “make the first letter lowercase” and “prepend Of” in order.

To “make the first letter lowercase,” we may rewrite the first letter with a new letter, or use a function that turns the entire string into lowercase (using the fact that the other characters are originally lowercase).

To “prepend Of,” the simplest way is to use a standard concatenation.

Sample code (Python 3 and C++)

The following is sample code in Python3.

s = input()
ans = "Of" + s.lower()
print(ans)

The following is sample code in C++.

#include <iostream>
using std::cin;
using std::cout;
#include <string>
using std::string;
#include <algorithm>
using std::tolower;

int main (void) {
	string s;
	cin >> s;
	
	string ans = s;
	ans[0] = tolower(ans[0]);
	ans = "Of" + ans;

	cout << ans << "\n";

	return 0;
}

投稿日時:
最終更新: