Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 100 点
問題文
英小文字からなる文字列 S が与えられます。
S の先頭から a 文字目と b 文字目を入れ替えて得られる文字列を出力してください。
制約
- S は英小文字からなる文字列
- S の長さ |S| は、 2 \leq |S| \leq 10 を満たす
- 1 \leq a < b \leq |S|
- a, b は整数
入力
入力は以下の形式で標準入力から与えられる。
S a b
出力
答えを出力せよ。
入力例 1
chokudai 3 5
出力例 1
chukodai
chokudai
の 3 文字目 o
と 5 文字目 u
を入れ替えると chukodai
となります。
入力例 2
aa 1 2
出力例 2
aa
この入力例では、S の 1 文字目と 2 文字目を入れ替えて得られる文字列は、元の S と同じになります。
入力例 3
aaaabbbb 1 8
出力例 3
baaabbba
Score : 100 points
Problem Statement
You are given a string S consisting of lowercase English letters.
Swap the a-th and b-th characters from the beginning of S and print the resulting string.
Constraints
- S is a string consisting of lowercase English letters.
- The length of S, |S|, satisfies 2 \leq |S| \leq 10.
- 1 \leq a < b \leq |S|
- a and b are integers.
Input
Input is given from Standard Input in the following format:
S a b
Output
Print the answer.
Sample Input 1
chokudai 3 5
Sample Output 1
chukodai
After swapping the 3-rd character o
and 5-th character u
of chokudai
, we have chukodai
.
Sample Input 2
aa 1 2
Sample Output 2
aa
In this sample, after swapping the 1-st and 2-nd characters of S, we have the same string as S.
Sample Input 3
aaaabbbb 1 8
Sample Output 3
baaabbba
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 100 点
問題文
キーエンスでは、役割や年齢、立場の違いに関係なく「さん」付けして呼ぶという文化があります。 新入社員が社長を呼ぶときも「中田さん」と呼びます。
ある人の苗字と名前がそれぞれ文字列 S,T として与えられます。
苗字、スペース(
)、敬称(san
)をこの順に連結した文字列を出力してください。
制約
- S,T は以下の各条件を満たす文字列
- 長さ 1 以上 10 以下
- 先頭の文字は英大文字
- 先頭以外の文字は英小文字
入力
入力は以下の形式で標準入力から与えられる。
S T
出力
苗字、スペース(
)、敬称(san
)をこの順に連結した文字列を出力せよ。
入力例 1
Takahashi Chokudai
出力例 1
Takahashi san
苗字(Takahashi
)、スペース(
)、敬称(san
)をこの順に連結した文字列を出力します。
入力例 2
K Eyence
出力例 2
K san
Score : 100 points
Problem Statement
Keyence has a culture of addressing everyone with the honorific "san," regardless of their role, age, or position. Even a new employee would call the president "Nakata-san." [Translator's note: this is a bit unusual in Japan.]
You are given a person's surname and first name as strings S and T, respectively.
Print the concatenation of the surname, a space (
), and the honorific (san
) in this order.
Constraints
- Each of S and T is a string that satisfies the following conditions.
- The length is between 1 and 10, inclusive.
- The first character is an uppercase English letter.
- All characters except the first one are lowercase English letters.
Input
The input is given from Standard Input in the following format:
S T
Output
Print the concatenation of the surname, a space (
), and the honorific (san
) in this order.
Sample Input 1
Takahashi Chokudai
Sample Output 1
Takahashi san
Print the concatenation of the surname (Takahashi
), a space (
), and the honorific (san
) in this order.
Sample Input 2
K Eyence
Sample Output 2
K san
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 200 点
問題文
英小文字からなる文字列 S,T が与えられるので、 T が S の(連続する)部分文字列かどうか判定してください。
なお、文字列 X に以下の操作を 0 回以上施して文字列 Y が得られる時、またその時に限り Y は X の(連続する)部分文字列であると言います。
- 以下の 2 つの操作から 1 つを選択して、その操作を行う。
- X の先頭の 1 文字を削除する。
- X の末尾の 1 文字を削除する。
例えば tag
は voltage
の(連続する)部分文字列ですが、 ace
は atcoder
の(連続する)部分文字列ではありません。
制約
- S,T は英小文字からなる
- 1 \le |S|,|T| \le 100 ( |X| は文字列 X の長さ )
入力
入力は以下の形式で標準入力から与えられる。
S T
出力
T が S の(連続する)部分文字列なら Yes
、そうでないなら No
と出力せよ。
入力例 1
voltage tag
出力例 1
Yes
tag
は voltage
の(連続する)部分文字列です。
入力例 2
atcoder ace
出力例 2
No
ace
は atcoder
の(連続する)部分文字列ではありません。
入力例 3
gorilla gorillagorillagorilla
出力例 3
No
入力例 4
toyotasystems toyotasystems
出力例 4
Yes
S=T である場合もあります。
Score : 200 points
Problem Statement
You are given strings S and T consisting of lowercase English letters. Determine whether T is a (contiguous) substring of S.
A string Y is said to be a (contiguous) substring of X if and only if Y can be obtained by performing the operation below on X zero or more times.
- Do one of the following.
- Delete the first character in X.
- Delete the last character in X.
For instance, tag
is a (contiguous) substring of voltage
, while ace
is not a (contiguous) substring of atcoder
.
Constraints
- S and T consist of lowercase English letters.
- 1 \le |S|,|T| \le 100 (|X| denotes the length of a string X.)
Input
The input is given from Standard Input in the following format:
S T
Output
If T is a (contiguous) substring of S, print Yes
; otherwise, print No
.
Sample Input 1
voltage tag
Sample Output 1
Yes
tag
is a (contiguous) substring of voltage
.
Sample Input 2
atcoder ace
Sample Output 2
No
ace
is not a (contiguous) substring of atcoder
.
Sample Input 3
gorilla gorillagorillagorilla
Sample Output 3
No
Sample Input 4
toyotasystems toyotasystems
Sample Output 4
Yes
It is possible that S=T.
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 200 点
問題文
整数 A,B が K 進法表記で与えられます。
A \times B を 10 進法表記で出力してください。
注記
K 進法表記については、Wikipedia「位取り記数法」 を参照してください。
制約
- 2 \leq K \leq 10
- 1 \leq A,B \leq 10^5
- A,B は K 進法表記で与えられる
入力
入力は以下の形式で標準入力から与えられる。
K A B
出力
答えを出力せよ。
入力例 1
2 1011 10100
出力例 1
220
2 進法表記の 1011
を 、10 進法表記すると 11 です。
2 進法表記の 10100
を、 10 進法表記すると 20 です。
11 \times 20 = 220 なので 220 を出力します。
入力例 2
7 123 456
出力例 2
15642
7 進法表記の 123
を 、10 進法表記すると 66 です。
7 進法表記の 456
を、 10 進法表記すると 237 です。
66 \times 237 = 15642 なので 15642 を出力します。
Score : 200 points
Problem Statement
You are given integers A and B, in base K.
Print A \times B in decimal.
Notes
For base-K representation, see Wikipedia's article on Positional notation.
Constraints
- 2 \leq K \leq 10
- 1 \leq A,B \leq 10^5
- A and B are in base-K representation.
Input
Input is given from Standard Input in the following format:
K A B
Output
Print the answer.
Sample Input 1
2 1011 10100
Sample Output 1
220
1011
in base 2 corresponds to 11 in base 10.
10100
in base 2 corresponds to 20 in base 10.
We have 11 \times 20 = 220, so print 220.
Sample Input 2
7 123 456
Sample Output 2
15642
123
in base 7 corresponds to 66 in base 10.
456
in base 7 corresponds to 237 in base 10.
We have 66 \times 237 = 15642, so print 15642.
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 300 点
問題文
10 進法で表記したときに 0,2 のみからなる正整数のうち、 K 番目に小さいものを求めてください。
制約
- K は 1 以上 10^{18} 以下の整数
入力
入力は以下の形式で標準入力から与えられる。
K
出力
答えを整数として出力せよ。
ただし、たとえ答えが大きな整数であっても、求める答えを正確に整数として出力する必要がある。たとえば、 2.34e+22
のような指数表記や、 0523
のような先頭に不要な 0 を付けたような表記は許されない。
入力例 1
3
出力例 1
22
10 進法で表記した時に 0,2 のみからなる正整数を小さい方から並べると、 2,20,22,\dots となります。
このうち K=3 番目である 22 を出力してください。
入力例 2
11
出力例 2
2022
入力例 3
923423423420220108
出力例 3
220022020000202020002022022000002020002222002200002022002200
たとえ答えが大きな整数であっても、求める答えを正確に整数として出力する必要があることに注意してください。
Score : 300 points
Problem Statement
Among the positive integers that consist of 0's and 2's when written in base 10, find the K-th smallest integer.
Constraints
- K is an integer between 1 and 10^{18} (inclusive).
Input
Input is given from Standard Input in the following format:
K
Output
Print the answer as an integer.
Here, the exact value must be printed as an integer, even if it is big. Exponential notations such as 2.34e+22
, for example, or unnecessary leading zeros such as 0523
are not allowed.
Sample Input 1
3
Sample Output 1
22
The positive integers that consist of 0's and 2's when written in base 10 are 2,20,22,\dots in ascending order.
The (K=) 3-rd of them, which is 22, should be printed.
Sample Input 2
11
Sample Output 2
2022
Sample Input 3
923423423420220108
Sample Output 3
220022020000202020002022022000002020002222002200002022002200
Note that the exact value of the answer must be printed as an integer, even if it is big.