Official
A - 202<s>3</s> Editorial 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.
There are several ways to change the last character 3
of a string \(S\) to 4
:
- Print all but last characters of \(S\), and then print
4
. - Remove the last character of \(S\), insert
4
to its tail, and print the resulting string.
Recheck how to handle strings (or arrays etc. corresponding to strings) in your language before implementing.
Sample code (Python):
s = str(input())
l = len(s)
for i in range(l-1):
print(s[i],end="")
print("4")
Sample code (C++):
#include<bits/stdc++.h>
using namespace std;
int main(){
string s;
cin >> s;
s.pop_back();
s.push_back('4');
cout << s << "\n";
return 0;
}
posted:
last update: