A - 22222

Time Limit: 2 sec / Memory Limit: 1024 MiB

配点 : 100

問題文

数字からなる文字列 S が与えられます。

S から 2 以外の文字を削除し、残った文字を順序を保って結合した文字列を求めてください。

制約

  • S は数字からなる長さ 1 以上 100 以下の文字列
  • S21 つ以上含む

入力

入力は以下の形式で標準入力から与えられる。

S

出力

答えを出力せよ。


入力例 1

20250222

出力例 1

22222

20250222 から 0, 5, 0 を削除し、残った文字を順序を保って結合することで文字列 22222 が得られます。


入力例 2

2

出力例 2

2

入力例 3

22222000111222222

出力例 3

22222222222

Score : 100 points

Problem Statement

You are given a string S consisting of digits.

Remove all characters from S except for 2, and then concatenate the remaining characters in their original order to form a new string.

Constraints

  • S is a string consisting of digits with length between 1 and 100, inclusive.
  • S contains at least one 2.

Input

The input is given from Standard Input in the following format:

S

Output

Print the answer.


Sample Input 1

20250222

Sample Output 1

22222

By removing 0, 5, and 0 from 20250222 and then concatenating the remaining characters in their original order, the string 22222 is obtained.


Sample Input 2

2

Sample Output 2

2

Sample Input 3

22222000111222222

Sample Output 3

22222222222
B - Filter

Time Limit: 2 sec / Memory Limit: 1024 MiB

配点 : 100

問題文

長さ N の整数列 A=(A _ 1,A _ 2,\ldots,A _ N) が与えられます。

A から偶数だけすべて取り出し、もとの順番を保って出力してください。

制約

  • 1\leq N\leq 100
  • 1\leq A _ i\leq 100\ (1\leq i\leq N)
  • A には 1 つ以上偶数が含まれる
  • 入力はすべて整数

入力

入力は以下の形式で標準入力から与えられる。

N
A _ 1 A _ 2 \ldots A _ N

出力

A から偶数を取り出した列を、空白区切りで 1 行に出力せよ。


入力例 1

5
1 2 3 5 6

出力例 1

2 6

A=(1,2,3,5,6) です。 このうち偶数なのは A _ 2=2,A _ 5=62 つなので、26 をこの順に空白区切りで出力してください。


入力例 2

5
2 2 2 3 3

出力例 2

2 2 2

A の中には同じ要素がある場合もあります。


入力例 3

10
22 3 17 8 30 15 12 14 11 17

出力例 3

22 8 30 12 14

Score : 100 points

Problem Statement

You are given a sequence of N integers: A=(A _ 1,A _ 2,\ldots,A _ N).

Print all even numbers in A without changing the order.

Constraints

  • 1\leq N\leq 100
  • 1\leq A _ i\leq 100\ (1\leq i\leq N)
  • A contains at least one even number.
  • All values in the input are integers.

Input

The input is given from Standard Input in the following format:

N
A _ 1 A _ 2 \ldots A _ N

Output

Print a line containing the sequence of all even numbers in A, with spaces in between.


Sample Input 1

5
1 2 3 5 6

Sample Output 1

2 6

We have A=(1,2,3,5,6). Among them are two even numbers, A _ 2=2 and A _ 5=6, so print 2 and 6 in this order, with a space in between.


Sample Input 2

5
2 2 2 3 3

Sample Output 2

2 2 2

A may contain equal elements.


Sample Input 3

10
22 3 17 8 30 15 12 14 11 17

Sample Output 3

22 8 30 12 14
C - Trifecta

Time Limit: 2 sec / Memory Limit: 1024 MiB

配点 : 200

問題文

1 から N の番号がついた N 頭の馬が競争をしました。

全ての馬は同時にスタートし、 i 番の馬はスタートからゴールまで T_i 秒かかりました。

1,2,3 着の馬の番号を求めてください。なお、 T_i は相異なることが保証されます。

制約

  • 3\leq N \leq 32
  • 1\leq T_i \leq 200
  • T_i は相異なる
  • 入力は全て整数

入力

入力は以下の形式で標準入力から与えられる。

N
T_1 \dots T_N

出力

1,2,3 着の馬の番号をそれぞれ空白区切りでこの順に出力せよ。


入力例 1

4
100 110 105 95

出力例 1

4 1 3

4,1,3,2 番の順にゴールしました。1,2,3 着の番号である 4,1,3 をこの順に空白区切りで出力してください。


入力例 2

8
72 74 69 70 73 75 71 77

出力例 2

3 4 7

Score : 200 points

Problem Statement

N horses numbered 1 to N had a race.

All horses started simultaneously, and horse i took T_i seconds from the start to the goal.

Find the numbers of the horses that finished in 1st, 2nd, and 3rd places. It is guaranteed that all T_i are distinct.

Constraints

  • 3\leq N \leq 32
  • 1\leq T_i \leq 200
  • All T_i are distinct.
  • All input values are integers.

Input

The input is given from Standard Input in the following format:

N
T_1 \dots T_N

Output

Output the numbers of the horses that finished in 1st, 2nd, and 3rd places, in this order, separated by spaces.


Sample Input 1

4
100 110 105 95

Sample Output 1

4 1 3

The horses finished in the order 4, 1, 3, 2. Output the numbers for 1st, 2nd, and 3rd places, which are 4, 1, 3, in this order, separated by spaces.


Sample Input 2

8
72 74 69 70 73 75 71 77

Sample Output 2

3 4 7
D - A^A

Time Limit: 2 sec / Memory Limit: 1024 MiB

配点 : 200

問題文

整数 B が与えられます。
A^A = B であるような正の整数 A が存在するならばその値を、存在しないならば -1 を出力してください。

制約

  • 1 \leq B \leq 10^{18}
  • B は整数

入力

入力は以下の形式で標準入力から与えられる。

B

出力

A^A = B であるような正の整数 A が存在するならばその値を、存在しないならば -1 を出力せよ。
A^A = B を満たす正の整数 A が複数ある場合は、どれを出力しても正解とみなされる。


入力例 1

27

出力例 1

3

3^3 = 27 なので 3 を出力します。


入力例 2

100

出力例 2

-1

A^A = B を満たす A は存在しません。


入力例 3

10000000000

出力例 3

10

Score : 200 points

Problem Statement

You are given an integer B.
If there exists a positive integer A such that A^A = B, print its value; otherwise, output -1.

Constraints

  • 1 \leq B \leq 10^{18}
  • B is an integer.

Input

The input is given from Standard Input in the following format:

B

Output

If there exists a positive integer A such that A^A = B, print its value; otherwise, print -1.
If there are multiple positive integers A such that A^A = B, any of them will be accepted.


Sample Input 1

27

Sample Output 1

3

3^3 = 27, so print 3.


Sample Input 2

100

Sample Output 2

-1

There is no A such that A^A = B.


Sample Input 3

10000000000

Sample Output 3

10
E - Airport Code

Time Limit: 2 sec / Memory Limit: 1024 MiB

配点 : 300

問題文

英大文字からなる長さ 3 の文字列 T が、英小文字からなる文字列 S空港コード であるとは、 TS から次のいずれかの方法により得られることとします。

  • S の長さ 3 の(連続とは限らない)部分列をとり、それを英大文字に変換したものを T とする
  • S の長さ 2 の(連続とは限らない)部分列をとり、それを英大文字に変換したものの末尾に X を追加したものを T とする

文字列 S, T が与えられるので、 TS の空港コードであるか判定してください。

制約

  • S は英小文字からなる長さ 3 以上 10^5 以下の文字列
  • T は英大文字からなる長さ 3 の文字列

入力

入力は以下の形式で標準入力から与えられる。

S
T

出力

TS の空港コードであるならば Yes を、そうでないならば No を出力せよ。


入力例 1

narita
NRT

出力例 1

Yes

narita の部分列 nrt を英大文字に変換した文字列 NRT は、 narita の空港コードです。


入力例 2

losangeles
LAX

出力例 2

Yes

losangeles の部分列 la を英大文字に変換した文字列 LA の末尾に X を追加したもの LAX は、 losangeles の空港コードです。


入力例 3

snuke
RNG

出力例 3

No

Score: 300 points

Problem Statement

A string T of length 3 consisting of uppercase English letters is an airport code for a string S of lowercase English letters if and only if T can be derived from S by one of the following methods:

  • Take a subsequence of length 3 from S (not necessarily contiguous) and convert it to uppercase letters to form T.
  • Take a subsequence of length 2 from S (not necessarily contiguous), convert it to uppercase letters, and append X to the end to form T.

Given strings S and T, determine if T is an airport code for S.

Constraints

  • S is a string of lowercase English letters with a length between 3 and 10^5, inclusive.
  • T is a string of uppercase English letters with a length of 3.

Input

The input is given from Standard Input in the following format:

S
T

Output

Print Yes if T is an airport code for S, and No otherwise.


Sample Input 1

narita
NRT

Sample Output 1

Yes

The subsequence nrt of narita, when converted to uppercase, forms the string NRT, which is an airport code for narita.


Sample Input 2

losangeles
LAX

Sample Output 2

Yes

The subsequence la of losangeles, when converted to uppercase and appended with X, forms the string LAX, which is an airport code for losangeles.


Sample Input 3

snuke
RNG

Sample Output 3

No