公式
A - Handmaid 解説 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.
- 「Python入門 AtCoder Programming Guide for beginners (APG4bPython)」 is a Python tutorial for competitive programmers. Again, this is only in Japanese.
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;
}
投稿日時:
最終更新: