A - Daily Cookie

Time Limit: 2 sec / Memory Limit: 1024 MiB

配点 : 100 点

問題文

N 個の箱が横一列に並んでおり、そのうちのいくつかの箱にはクッキーが入っています。

各箱の状態は長さ N の文字列 S によって表されます。 具体的には、左から i\ (1\leq i\leq N) 番目の箱は、S の i 文字目が @ のときクッキーが 1 枚入っており、. のとき空き箱です。

高橋君は今からの D 日間、一日一回ずつ、これらの箱のいずれかに入ったクッキーを 1 枚選んで食べます。

N 個の箱のうち、D 日間が経過した後に空き箱であるものはいくつあるか求めてください。 (この値は高橋君が各日でどのクッキーを選ぶかによらないことが証明できます。)

なお、S には @ が D 個以上含まれることが保証されます。

制約

  • 1\leq D \leq N \leq 100
  • N,D は整数
  • S は @ と . からなる長さ N の文字列
  • S には @ が D 個以上含まれる

入力

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

N D
S

出力

N 個の箱のうち、D 日間が経過した後に空き箱であるものの個数を出力せよ。


入力例 1

5 2
.@@.@

出力例 1

4

例えば、高橋君は以下のように行動する可能性があります。

  • 1 日目:左から 2,3,5 番目の箱にクッキーが入っている。左から 2 番目の箱に入っているクッキーを選んで食べる。
  • 2 日目:左から 3,5 番目の箱にクッキーが入っている。左から 5 番目の箱に入っているクッキーを選んで食べる。
  • 2 日間が経過した後、左から 3 番目の箱にのみクッキーが入っている。よって、5 個の箱のうち 4 箱が空き箱である。

高橋君が各日で選ぶクッキーはこの例とは異なる可能性もありますが、いずれにせよ 2 日間が経過した後には 4 箱が空き箱です。 よって答えは 4 です。


入力例 2

3 3
@@@

出力例 2

3

入力例 3

10 4
@@@.@@.@@.

出力例 3

7

Score: 100 points

Problem Statement

There are N boxes arranged in a row, and some of these boxes contain cookies.

The state of these boxes is represented by a string S of length N. Specifically, the i-th box (1\leq i \leq N) from the left contains one cookie if the i-th character of S is @, and is empty if it is ..

Over the next D days, Takahashi will choose and eat one cookie per day from among the cookies in these boxes.

Determine how many of the N boxes will be empty after D days have passed. (It can be proved that this value does not depend on which cookies Takahashi chooses each day.)

It is guaranteed that S contains at least D occurrences of @.

Constraints

  • 1 \leq D \leq N \leq 100
  • N and D are integers.
  • S is a string of length N consisting of @ and ..
  • S contains at least D occurrences of @.

Input

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

N D
S

Output

Print the number of boxes that will be empty after D days have passed among the N boxes.


Sample Input 1

5 2
.@@.@

Sample Output 1

4

For example, Takahashi might act as follows:

  • Day 1: There are cookies in the 2nd, 3rd, and 5th boxes from the left. He chooses the cookie in the 2nd box to eat.
  • Day 2: There are cookies in the 3rd and 5th boxes. He chooses the cookie in the 5th box to eat.
  • After two days have passed, only the 3rd box from the left contains a cookie. Therefore, four out of the five boxes are empty.

Even though Takahashi might choose differently on each day than in this example, there will still be four empty boxes after two days. Therefore, the answer is 4.


Sample Input 2

3 3
@@@

Sample Output 2

3

Sample Input 3

10 4
@@@.@@.@@.

Sample Output 3

7
B - Four Points

Time Limit: 2 sec / Memory Limit: 1024 MiB

配点 : 100 点

問題文

xy 平面上に長方形があります。この長方形の各辺は x 軸または y 軸に平行であり、面積は 0 ではありません。

この長方形の 4 つの頂点のうち異なる 3 つの頂点の座標 (x_1, y_1), (x_2, y_2), (x_3, y_3) が与えられるので、残る 1 つの頂点の座標を求めてください。

制約

  • -100 \leq x_i, y_i \leq 100
  • (x_1, y_1), (x_2, y_2), (x_3, y_3) のすべてを頂点に持つ長方形がただ一つ存在し、その各辺は x 軸または y 軸に平行であり、面積は 0 ではない。
  • 入力はすべて整数

入力

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

x_1 y_1
x_2 y_2
x_3 y_3

出力

答えとなる頂点の座標 (x, y) を下記の形式にしたがい空白区切りで出力せよ。

x y

入力例 1

-1 -1
-1 2
3 2

出力例 1

3 -1

(-1, -1), (-1, 2), (3, 2) を頂点とする長方形の残る 1 つの頂点は (3, -1) です。


入力例 2

-60 -40
-60 -80
-20 -80

出力例 2

-20 -40

Score : 100 points

Problem Statement

There is a rectangle in the xy-plane. Each edge of this rectangle is parallel to the x- or y-axis, and its area is not zero.

Given the coordinates of three of the four vertices of this rectangle, (x_1, y_1), (x_2, y_2), and (x_3, y_3), find the coordinates of the other vertex.

Constraints

  • -100 \leq x_i, y_i \leq 100
  • There uniquely exists a rectangle with all of (x_1, y_1), (x_2, y_2), (x_3, y_3) as vertices, edges parallel to the x- or y-axis, and a non-zero area.
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

x_1 y_1
x_2 y_2
x_3 y_3

Output

Print the sought coordinates (x, y) separated by a space in the following format:

x y

Sample Input 1

-1 -1
-1 2
3 2

Sample Output 1

3 -1

The other vertex of the rectangle with vertices (-1, -1), (-1, 2), (3, 2) is (3, -1).


Sample Input 2

-60 -40
-60 -80
-20 -80

Sample Output 2

-20 -40
C - Cut .0

Time Limit: 2 sec / Memory Limit: 1024 MiB

配点 : 150 点

問題文

実数 X が小数点以下第 3 位まで与えられます。

実数 X を以下の条件を満たすように出力してください。

  • 小数点以下の部分について、末尾に 0 を付けない
  • 末尾に過剰な小数点を付けない

制約

  • 0 \le X < 100
  • X は小数点以下第 3 位まで与えられる

入力

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

X

出力

答えを出力せよ。


入力例 1

1.012

出力例 1

1.012

1.012 はそのまま出力しても構いません。


入力例 2

12.340

出力例 2

12.34

12.340 を末尾に 0 を付けずに出力すると 12.34 となります。


入力例 3

99.900

出力例 3

99.9

99.900 を末尾に 0 を付けずに出力すると 99.9 となります。


入力例 4

0.000

出力例 4

0

0.000 を末尾に 0 や過剰な小数点を付けずに出力すると 0 となります。

Score : 150 points

Problem Statement

A real number X is given to the third decimal place.

Print the real number X under the following conditions.

  • The decimal part must not have trailing 0s.
  • There must not be an unnecessary trailing decimal point.

Constraints

  • 0 \le X < 100
  • X is given to the third decimal place.

Input

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

X

Output

Output the answer.


Sample Input 1

1.012

Sample Output 1

1.012

1.012 can be printed as it is.


Sample Input 2

12.340

Sample Output 2

12.34

Printing 12.340 without the trailing 0 results in 12.34.


Sample Input 3

99.900

Sample Output 3

99.9

Printing 99.900 without the trailing 0s results in 99.9.


Sample Input 4

0.000

Sample Output 4

0

Printing 0.000 without trailing 0s or an unnecessary decimal point results in 0.

D - Center Alignment

Time Limit: 2 sec / Memory Limit: 1024 MiB

配点 : 200 点

問題文

英小文字からなる N 個の奇数長の文字列 S_1,S_2,\dots,S_N が与えられます。

S_1,S_2,\dots,S_N のうち最も長いものの長さを m とします。 以下の条件を満たす文字列 T_1,T_2,\dots,T_N を求めてください。

  • 条件:T_i はある非負整数 k について k 個の .、S_i、k 個の . をこの順に結合してできる、長さ m の文字列である。

制約

  • N は 1 以上 100 以下の整数
  • S_i は英小文字からなる長さ 1 以上 99 以下の奇数長の文字列

入力

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

N
S_1
S_2
\vdots
S_N

出力

N 行出力せよ。i\ (1 \leq i \leq N) 行目には T_i を出力せよ。


入力例 1

4
apple
blueberry
coconut
dragonfruit

出力例 1

...apple...
.blueberry.
..coconut..
dragonfruit

m=11 であり、T_1,T_2,T_3,T_4 はそれぞれ k=3,1,2,0 について問題文中の条件を満たしています。


入力例 2

6
abc
d
efghi
jkl
mnopq
r

出力例 2

.abc.
..d..
efghi
.jkl.
mnopq
..r..

Score : 200 points

Problem Statement

You are given N strings S_1,S_2,\dots,S_N of odd lengths consisting of lowercase English letters.

Let m be the length of the longest string among S_1,S_2,\dots,S_N. Find strings T_1,T_2,\dots,T_N satisfying the following condition.

  • Condition: T_i is a string of length m formed by concatenating k copies of ., S_i, and k copies of . in this order, for some non-negative integer k.

Constraints

  • N is an integer between 1 and 100, inclusive.
  • S_i is a string of odd length between 1 and 99, inclusive, consisting of lowercase English letters.

Input

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

N
S_1
S_2
\vdots
S_N

Output

Output N lines. The i-th line (1 \leq i \leq N) should contain T_i.


Sample Input 1

4
apple
blueberry
coconut
dragonfruit

Sample Output 1

...apple...
.blueberry.
..coconut..
dragonfruit

m=11, and T_1,T_2,T_3,T_4 satisfy the condition in the problem statement for k=3,1,2,0, respectively.


Sample Input 2

6
abc
d
efghi
jkl
mnopq
r

Sample Output 2

.abc.
..d..
efghi
.jkl.
mnopq
..r..
E - Snake Numbers

Time Limit: 2 sec / Memory Limit: 1024 MiB

配点 : 350 点

問題文

10 以上の正整数のうち、十進数表記したときに先頭の桁(最も大きい位)の数字がそれ以外のどの桁の数字よりも真に大きくなるようなものを ヘビ数 とよびます。 例えば、31 や 201 はヘビ数ですが、35 や 202 はヘビ数ではありません。

L 以上 R 以下のヘビ数が何個あるか求めてください。

制約

  • 10\leq L \leq R \leq 10^{18}
  • 入力は全て整数

入力

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

L R

出力

答えを出力せよ。


入力例 1

97 210

出力例 1

6

97 以上 210 以下のヘビ数は、97,98,100,200,201,210 の 6 個です。


入力例 2

1000 9999

出力例 2

2025

入力例 3

252509054433933519 760713016476190692

出力例 3

221852052834757

Score : 350 points

Problem Statement

A positive integer not less than 10 whose top digit (the most significant digit) in decimal representation is strictly larger than every other digit in that number is called a Snake number. For example, 31 and 201 are Snake numbers, but 35 and 202 are not.

Find how many Snake numbers exist between L and R, inclusive.

Constraints

  • 10 \leq L \leq R \leq 10^{18}
  • All input values are integers.

Input

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

L R

Output

Print the answer.


Sample Input 1

97 210

Sample Output 1

6

The Snake numbers between 97 and 210, inclusive, are 97, 98, 100, 200, 201, and 210: there are six.


Sample Input 2

1000 9999

Sample Output 2

2025

Sample Input 3

252509054433933519 760713016476190692

Sample Output 3

221852052834757