Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 150 点
問題文
A, B, C の三兄弟がいます。この 3 人の年齢関係は、3 つの文字 S_{\mathrm{AB}},S_{\mathrm{AC}},S_{\mathrm{BC}} によって与えられ、それぞれ以下を意味します。
- S_{\mathrm{AB}} が
<
の場合 A は B より年下であり、>
の場合 A は B より年上である。 - S_{\mathrm{AC}} が
<
の場合 A は C より年下であり、>
の場合 A は C より年上である。 - S_{\mathrm{BC}} が
<
の場合 B は C より年下であり、>
の場合 B は C より年上である。
三兄弟の次男、つまり二番目に年上の人は誰ですか?
制約
- S_{\mathrm{AB}},S_{\mathrm{AC}},S_{\mathrm{BC}} はそれぞれ
<
または>
- 入力に矛盾は含まれない。つまり、与えられた大小関係を全て満たす年齢関係が必ず存在する入力のみが与えられる。
入力
入力は以下の形式で標準入力から与えられる。
S_{\mathrm{AB}} S_{\mathrm{AC}} S_{\mathrm{BC}}
出力
三兄弟の次男、つまり二番目に年上の人の名前を出力せよ。
入力例 1
< < <
出力例 1
B
A が B より年下であり、B が C より年下であることから、C が長男、B が次男、A が三男であることがわかります。よって答えは B
です。
入力例 2
< < >
出力例 2
C
Score : 150 points
Problem Statement
There are three brothers named A
, B
, and C
. The age relationships among them are given by three characters S_{\mathrm{AB}}, S_{\mathrm{AC}}, S_{\mathrm{BC}}, which mean the following:
- If S_{\mathrm{AB}} is
<
, then A is younger than B; if it is>
, then A is older than B. - If S_{\mathrm{AC}} is
<
, then A is younger than C; if it is>
, then A is older than C. - If S_{\mathrm{BC}} is
<
, then B is younger than C; if it is>
, then B is older than C.
Who is the middle brother, that is, the second oldest among the three?
Constraints
- Each of S_{\mathrm{AB}}, S_{\mathrm{AC}}, S_{\mathrm{BC}} is
<
or>
. - The input contains no contradictions; that is, there always exists an age relationship that satisfies all given inequalities.
Input
The input is given from Standard Input in the following format:
S_{\mathrm{AB}} S_{\mathrm{AC}} S_{\mathrm{BC}}
Output
Print the name of the middle brother, that is, the second oldest among the three.
Sample Input 1
< < <
Sample Output 1
B
Since A is younger than B, and B is younger than C, we can determine that C is the oldest, B is the middle, and A is the youngest. Hence, the answer is B
.
Sample Input 2
< < >
Sample Output 2
C
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 100 点
問題文
英小文字からなる文字列 S が与えられます。
S から a
, e
, i
, o
, u
をすべて取り除いて得られる文字列を出力してください。
なお、S は a
, e
, i
, o
, u
以外の文字を一つ以上含みます。
制約
- S は英小文字からなる長さ 1 以上 100 以下の文字列
- S は
a
,e
,i
,o
,u
以外の文字を一つ以上含む
入力
入力は以下の形式で標準入力から与えられる。
S
出力
答えを出力せよ。
入力例 1
atcoder
出力例 1
tcdr
S = atcoder
のとき、1, 4, 6 文字目を取り除いて tcdr
を得ます。
入力例 2
xyz
出力例 2
xyz
入力例 3
aaaabbbbcccc
出力例 3
bbbbcccc
Score : 100 points
Problem Statement
You are given a string S consisting of lowercase English letters.
Remove all occurrences of a
, e
, i
, o
, u
from S and print the resulting string.
S contains at least one character other than a
, e
, i
, o
, u
.
Constraints
- S is a string of length between 1 and 100, inclusive, consisting of lowercase English letters.
- S contains at least one character other than
a
,e
,i
,o
,u
.
Input
The input is given from Standard Input in the following format:
S
Output
Print the answer.
Sample Input 1
atcoder
Sample Output 1
tcdr
For S = atcoder
, remove the 1-st, 4-th, and 6-th characters to get tcdr
.
Sample Input 2
xyz
Sample Output 2
xyz
Sample Input 3
aaaabbbbcccc
Sample Output 3
bbbbcccc
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 200 点
問題文
00
, 0
, 1
, 2
, 3
, 4
, 5
, 6
, 7
, 8
, 9
のボタンがある電卓があります。
この電卓で文字列 x が表示されている時に b のボタンを押すと、表示される文字列は x の末尾に b を連結したものとなります。
最初、電卓には空文字列 ( 0 文字の文字列 ) が表示されています。
この電卓に文字列 S を表示させるためにボタンを押す回数の最小値を求めてください。
制約
- S は
0
,1
,2
,3
,4
,5
,6
,7
,8
,9
からなる長さ 1 以上 1000 以下の列 - S の先頭は
0
でない
入力
入力は以下の形式で標準入力から与えられる。
S
出力
答えを整数として出力せよ。
入力例 1
1000000007
出力例 1
6
1000000007
を表示させるには、 1
, 00
, 00
, 00
, 00
, 7
のボタンをこの順に押せばよく、ボタンを押した回数は 6 回で、これが達成可能な最小値です。
入力例 2
998244353
出力例 2
9
入力例 3
32000
出力例 3
4
Score : 200 points
Problem Statement
There is a calculator with the buttons 00
, 0
, 1
, 2
, 3
, 4
, 5
, 6
, 7
, 8
, 9
.
When a string x is displayed on this calculator and you press a button b, the resulting displayed string becomes the string x with b appended to its end.
Initially, the calculator displays the empty string (a string of length 0).
Find the minimum number of button presses required to display the string S on this calculator.
Constraints
- S is a string of length at least 1 and at most 1000, consisting of
0
,1
,2
,3
,4
,5
,6
,7
,8
,9
. - The first character of S is not
0
.
Input
The input is given from Standard Input in the following format:
S
Output
Print the answer as an integer.
Sample Input 1
1000000007
Sample Output 1
6
To display 1000000007
, you can press the buttons 1
, 00
, 00
, 00
, 00
, 7
in this order. The total number of button presses is 6, and this is the minimum possible.
Sample Input 2
998244353
Sample Output 2
9
Sample Input 3
32000
Sample Output 3
4
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 200 点
問題文
高橋君は電卓を持っています。電卓には最初 1 が表示されています。
高橋君は電卓に対して N 回操作を行います。
i 回目 (1\leq i\leq N) の操作では、その時点で画面に表示されている数に正の整数 A_i をかけます。
しかし、電卓には K 桁までしか表示できないため、計算結果が (K+1) 桁以上になる場合、代わりに 1 が画面に表示されます。
そうでない場合は正しく計算結果が表示されます。
N 回の操作の後に電卓に表示されている数を求めてください。
制約
- 1 \leq N \leq 100
- 1 \leq K \leq 18
- 1 \leq A_i < 10^K
- 入力はすべて整数
入力
入力は以下の形式で標準入力から与えられる。
N K A_1 A_2 \ldots A_N
出力
N 回の操作の後に電卓に表示されている数を出力せよ。
入力例 1
5 2 7 13 3 2 5
出力例 1
10
今回電卓は 2 桁まで表示することができ、最初 1 が表示されています。これに対して、次のように高橋君は操作を行います。
- 1 回目の操作で、7 をかけます。1\times 7=7 であり、電卓には 7 が表示されます。
- 2 回目の操作で、13 をかけます。7\times 13=91 であり、電卓には 91 が表示されます。
- 3 回目の操作で、3 をかけます。91\times 3=273 であり、3 桁になってしまうため、電卓には 1 が表示されます。
- 4 回目の操作で、2 をかけます。1\times 2=2 であり、電卓には 2 が表示されます。
- 5 回目の操作で、5 をかけます。2\times 5=10 であり、電卓には 10 が表示されます。
入力例 2
2 1 2 5
出力例 2
1
Score : 200 points
Problem Statement
Takahashi has a calculator that initially displays 1.
He will perform N operations on the calculator.
In the i-th operation (1 \leq i \leq N), he multiplies the currently displayed number by a positive integer A_i.
However, the calculator can display at most K digits.
If the result of the multiplication has (K+1) or more digits, the display shows 1 instead; otherwise, the result is shown correctly.
Find the number showing on the calculator after the N operations.
Constraints
- 1 \leq N \leq 100
- 1 \leq K \leq 18
- 1 \leq A_i < 10^K
- All input values are integers.
Input
The input is given from Standard Input in the following format:
N K A_1 A_2 \ldots A_N
Output
Output the number shown on the calculator after the N operations.
Sample Input 1
5 2 7 13 3 2 5
Sample Output 1
10
This calculator can display at most two digits and initially shows 1. Takahashi operates as follows:
- The 1st operation multiplies by 7. Since 1 \times 7 = 7, the calculator shows 7.
- The 2nd operation multiplies by 13. Since 7 \times 13 = 91, the calculator shows 91.
- The 3rd operation multiplies by 3. Since 91\times 3=273, which has three digits, the calculator shows 1.
- The 4th operation multiplies by 2. Since 1\times 2=2, the calculator shows 2.
- The 5th operation multiplies by 5. Since 2\times 5=10, the calculator shows 10.
Sample Input 2
2 1 2 5
Sample Output 2
1
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 300 点
問題文
英小文字からなる文字列 S, T が与えられます。ここで、S と T の長さは等しいです。
X を空の配列とし、以下の操作を S と T が等しくなるまで繰り返します。
- S の文字を 1 文字書き換え、X の末尾に S を追加する。
こうして得られる文字列の配列 X のうち要素数最小のものを求めてください。要素数最小のものが複数考えられる場合は、そのうち辞書順最小のものを求めてください。
文字列の配列の辞書順とは
長さ N の文字列 S = S_1 S_2 \ldots S_N が長さ N の文字列 T = T_1 T_2 \ldots T_N より辞書順で小さいとは、ある整数 1 \leq i \leq N が存在して下記の 2 つがともに成り立つことをいいます。
- S_1 S_2 \ldots S_{i-1} = T_1 T_2 \ldots T_{i-1}
- S_i が T_i よりアルファベット順で早い。
要素数 M の文字列の配列 X = (X_1,X_2,\ldots,X_M) が要素数 M の文字列の配列 Y = (Y_1,Y_2,\ldots,Y_M) より辞書順で小さいとは、ある整数 1 \leq j \leq M が存在して下記の 2 つがともに成り立つことをいいます。
- (X_1,X_2,\ldots,X_{j-1}) = (Y_1,Y_2,\ldots,Y_{j-1})
- X_j が Y_j より辞書順で小さい。
制約
- S, T は英小文字からなる長さ 1 以上 100 以下の文字列
- S と T の長さは等しい
入力
入力は以下の形式で標準入力から与えられる。
S T
出力
答えの要素数を M として M + 1 行出力せよ。
1 行目には M の値を出力せよ。
i + 1 (1 \leq i \leq M) 行目には答えの i 番目の要素を出力せよ。
入力例 1
adbe bcbc
出力例 1
3 acbe acbc bcbc
はじめ、S = adbe
です。
以下のように操作することで、X = ( acbe
, acbc
, bcbc
) とすることができます。
-
S を
acbe
に書き換え、X の末尾にacbe
を追加する。 -
S を
acbc
に書き換え、X の末尾にacbc
を追加する。 -
S を
bcbc
に書き換え、X の末尾にbcbc
を追加する。
入力例 2
abcde abcde
出力例 2
0
入力例 3
afwgebrw oarbrenq
出力例 3
8 aawgebrw aargebrw aarbebrw aarbebnw aarbebnq aarbeenq aarbrenq oarbrenq
Score : 300 points
Problem Statement
You are given two strings S and T consisting of lowercase English letters. Here, S and T have equal lengths.
Let X be an empty array, and repeat the following operation until S equals T:
- Change one character in S, and append S to the end of X.
Find the array of strings X with the minimum number of elements obtained in this way. If there are multiple such arrays with the minimum number of elements, find the lexicographically smallest one among them.
What is lexicographical order on arrays of strings?
A string S = S_1 S_2 \ldots S_N of length N is lexicographically smaller than a string T = T_1 T_2 \ldots T_N of length N if there exists an integer 1 \leq i \leq N such that both of the following are satisfied:
- S_1 S_2 \ldots S_{i-1} = T_1 T_2 \ldots T_{i-1}
- S_i comes earlier than T_i in alphabetical order.
An array of strings X = (X_1,X_2,\ldots,X_M) with M elements is lexicographically smaller than an array of strings Y = (Y_1,Y_2,\ldots,Y_M) with M elements if there exists an integer 1 \leq j \leq M such that both of the following are satisfied:
- (X_1,X_2,\ldots,X_{j-1}) = (Y_1,Y_2,\ldots,Y_{j-1})
- X_j is lexicographically smaller than Y_j.
Constraints
- S and T are strings consisting of lowercase English letters with length between 1 and 100, inclusive.
- The lengths of S and T are equal.
Input
The input is given from Standard Input in the following format:
S T
Output
Let M be the number of elements in the desired array. Print M + 1 lines.
The first line should contain the value of M.
The i + 1-th line (1 \leq i \leq M) should contain the i-th element of the array.
Sample Input 1
adbe bcbc
Sample Output 1
3 acbe acbc bcbc
Initially, S = adbe
.
We can obtain X = ( acbe
, acbc
, bcbc
) by performing the following operations:
-
Change S to
acbe
and appendacbe
to the end of X. -
Change S to
acbc
and appendacbc
to the end of X. -
Change S to
bcbc
and appendbcbc
to the end of X.
Sample Input 2
abcde abcde
Sample Output 2
0
Sample Input 3
afwgebrw oarbrenq
Sample Output 3
8 aawgebrw aargebrw aarbebrw aarbebnw aarbebnq aarbeenq aarbrenq oarbrenq