A - Exponential or Quadratic

Time Limit: 2 sec / Memory Limit: 1024 MiB

配点 : 100

問題文

2^n \gt n^2 ですか?

制約

  • n1 以上 10^9 以下の整数

入力

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

n

出力

2^n \gt n^2 なら Yes を、そうでないなら No を出力せよ。


入力例 1

5

出力例 1

Yes

2^5=32,\ 5^2=25 より 2^n \gt n^2 であるため、Yes を出力します。


入力例 2

2

出力例 2

No

n=2 の場合 2^n=n^2=2^2 となり、故に 2^n \gt n^2 ではありません。よって No を出力します。


入力例 3

623947744

出力例 3

Yes

Score : 100 points

Problem Statement

Does 2^n \gt n^2 hold?

Constraints

  • n is an integer between 1 and 10^9 (inclusive).

Input

Input is given from Standard Input in the following format:

n

Output

If 2^n \gt n^2, print Yes; otherwise, print No.


Sample Input 1

5

Sample Output 1

Yes

Since 2^5=32,\ 5^2=25, we have 2^n \gt n^2, so Yes should be printed.


Sample Input 2

2

Sample Output 2

No

For n=2, we have 2^n=n^2=2^2, so 2^n \gt n^2 does not hold. Thus, No should be printed.


Sample Input 3

623947744

Sample Output 3

Yes
B - Seismic magnitude scales

Time Limit: 2 sec / Memory Limit: 1024 MiB

配点 : 100

問題文

地震のマグニチュードは、その地震のエネルギーの大きさを対数で表した値です。マグニチュードが 1 増える度にエネルギーは約 32 倍になることが知られています。
ここではマグニチュードが 1 増える度に地震のエネルギーがちょうど 32 倍になるとします。このとき、マグニチュード A の地震のエネルギーの大きさはマグニチュード B の地震のエネルギーの大きさの何倍ですか?

制約

  • 3\leq B\leq A\leq 9
  • A , B は整数

入力

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

A B

出力

答えを整数で出力せよ。


入力例 1

6 4

出力例 1

1024

64 より 2 だけ大きいので、 マグニチュード 6 の地震はマグニチュード 4 の地震と比べて 32\times 32=1024 倍のエネルギーを持っています。


入力例 2

5 5

出力例 2

1

マグニチュードが同じなのでエネルギーの大きさも同じです。

Score : 100 points

Problem Statement

The magnitude of an earthquake is a logarithmic scale of the energy released by the earthquake. It is known that each time the magnitude increases by 1, the amount of energy gets multiplied by approximately 32.
Here, we assume that the amount of energy gets multiplied by exactly 32 each time the magnitude increases by 1. In this case, how many times is the amount of energy of a magnitude A earthquake as much as that of a magnitude B earthquake?

Constraints

  • 3\leq B\leq A\leq 9
  • A and B are integers.

Input

Input is given from Standard Input in the following format:

A B

Output

Print the answer as an integer.


Sample Input 1

6 4

Sample Output 1

1024

6 is 2 greater than 4, so a magnitude 6 earthquake has 32\times 32=1024 times as much energy as a magnitude 4 earthquake has.


Sample Input 2

5 5

Sample Output 2

1

Earthquakes with the same magnitude have the same amount of energy.

C - Caesar Cipher

Time Limit: 2 sec / Memory Limit: 1024 MiB

配点 : 200

問題文

高橋君は英小文字からなる文字列 S を持っています。

高橋君は文字列 S に対して、下記の操作をちょうど 1 回行います。

  • まず、非負整数 K を選ぶ。
  • その後、S の各文字を K 個後ろの英小文字に変更する。

ただし、

  • a1 個後ろの英小文字は b であり、
  • b1 個後ろの英小文字は c であり、
  • c1 個後ろの英小文字は d であり、
  • \cdots
  • y1 個後ろの英小文字は z であり、
  • z1 個後ろの英小文字は a です。

例えば、b4 個後ろの英小文字は f であり、y3 個後ろの英小文字は b です。

文字列 T が与えられます。 高橋君が上記の操作によって ST に一致させることができるかを判定してください。

制約

  • ST はそれぞれ英小文字からなる長さ 1 以上 10^5 以下の文字列
  • S の長さと T の長さは等しい

入力

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

S
T

出力

高橋君が ST に一致させることができる場合は Yes と出力し、 できない場合は No と出力せよ。


入力例 1

abc
ijk

出力例 1

Yes

高橋君が K=8 を選ぶと、

  • a8 個後ろの i
  • b8 個後ろの j
  • c8 個後ろの k

それぞれ変更され、ST が一致します。
高橋君が ST に一致させることができるため Yes と出力します。


入力例 2

z
a

出力例 2

Yes

高橋君が K=1 を選ぶと ST が一致します。
z1 個後ろの英小文字は a であることに注意してください。


入力例 3

ppq
qqp

出力例 3

No

高橋君は非負整数 K をどのように選んでも ST に一致させることができません。 よって、No と出力します。


入力例 4

atcoder
atcoder

出力例 4

Yes

高橋君が K=0 を選ぶと ST が一致します。

Score : 200 points

Problem Statement

Takahashi has a string S consisting of lowercase English letters.

On this string, he will do the operation below just once.

  • First, choose a non-negative integer K.
  • Then, shift each character of S to the right by K (see below).

Here,

  • a shifted to the right by 1 is b;
  • b shifted to the right by 1 is c;
  • c shifted to the right by 1 is d;
  • \cdots
  • y shifted to the right by 1 is z;
  • z shifted to the right by 1 is a.

For example, b shifted to the right by 4 is f, and y shifted to the right by 3 is b.

You are given a string T. Determine whether Takahashi can make S equal T by the operation above.

Constraints

  • Each of S and T is a string of length between 1 and 10^5 (inclusive) consisting of lowercase English letters.
  • The lengths of S and T are equal.

Input

Input is given from Standard Input in the following format:

S
T

Output

If Takahashi can make S equal T, print Yes; if not, print No.


Sample Input 1

abc
ijk

Sample Output 1

Yes

When Takahashi chooses K=8,

  • a is shifted to the right by 8 and becomes i,
  • b is shifted to the right by 8 and becomes j,
  • c is shifted to the right by 8 and becomes k,

and now S and T are equal.
Therefore, he can make S equal T, so Yes should be printed.


Sample Input 2

z
a

Sample Output 2

Yes

Choosing K=1 makes S and T equal.
Note that the letter on the right of z is a.


Sample Input 3

ppq
qqp

Sample Output 3

No

There is no non-negative integer K that he can choose to make S equal T, so No should be printed.


Sample Input 4

atcoder
atcoder

Sample Output 4

Yes

Choosing K=0 makes S and T equal.

D - Who is missing?

Time Limit: 2 sec / Memory Limit: 1024 MiB

配点 : 200

問題文

整数 1, 2, \dots, N が書かれたカードが 4 枚ずつ、合計 4N 枚あります。

高橋君は、これらのカードをシャッフルしたのち 1 枚のカードを選んで抜き取り、残りの 4N - 1 枚を束にしてあなたに渡しました。渡された束の i \, (1 \leq i \leq 4N - 1) 枚目のカードには、整数 A_i が書かれています。

高橋君が抜き取ったカードに書かれていた整数を求めてください。

制約

  • 1 \leq N \leq 10^5
  • 1 \leq A_i \leq N \, (1 \leq i \leq 4N - 1)
  • k \, (1 \leq k \leq N) に対し、A_i = k となる i4 個以下である。
  • 入力は全て整数である。

入力

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

N
A_1 A_2 \ldots A_{4N - 1}

出力

答えを出力せよ。


入力例 1

3
1 3 2 3 3 2 2 1 1 1 2

出力例 1

3

高橋君が抜き取ったカードには 3 が書かれています。


入力例 2

1
1 1 1

出力例 2

1

入力例 3

4
3 2 1 1 2 4 4 4 4 3 1 3 2 1 3

出力例 3

2

Score : 200 points

Problem Statement

We have 4 cards with an integer 1 written on it, 4 cards with 2, \ldots, 4 cards with N, for a total of 4N cards.

Takahashi shuffled these cards, removed one of them, and gave you a pile of the remaining 4N-1 cards. The i-th card (1 \leq i \leq 4N - 1) of the pile has an integer A_i written on it.

Find the integer written on the card removed by Takahashi.

Constraints

  • 1 \leq N \leq 10^5
  • 1 \leq A_i \leq N \, (1 \leq i \leq 4N - 1)
  • For each k \, (1 \leq k \leq N), there are at most 4 indices i such that A_i = k.
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

N
A_1 A_2 \ldots A_{4N - 1}

Output

Print the answer.


Sample Input 1

3
1 3 2 3 3 2 2 1 1 1 2

Sample Output 1

3

Takahashi removed a card with 3 written on it.


Sample Input 2

1
1 1 1

Sample Output 2

1

Sample Input 3

4
3 2 1 1 2 4 4 4 4 3 1 3 2 1 3

Sample Output 3

2
E - A+B+C

Time Limit: 2 sec / Memory Limit: 1024 MiB

配点 : 250

問題文

3 個の数列 A=(A_1,\ldots,A_N), B=(B_1,\ldots,B_M), C=(C_1,\ldots,C_L) が与えられます。

さらに数列 X=(X_1,\ldots,X_Q) が与えられるので、各 i=1,\ldots,Q に対して次の問題を解いてください。

問題:A,B,C からそれぞれ 1 個ずつ要素を選び、和を X_i にすることができるか?

制約

  • 1 \leq N,M,L \leq 100
  • 0 \leq A_i, B_i ,C_i \leq 10^8
  • 1 \leq Q \leq 2\times 10^5
  • 0 \leq X_i \leq 3\times 10^8
  • 入力は全て整数である

入力

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

N
A_1 \ldots A_N
M
B_1 \ldots B_M
L
C_1 \ldots C_L
Q
X_1 \ldots X_Q

出力

Q 行出力せよ。
i 行目には、A,B,C からそれぞれ 1 個ずつ要素を選び和を X_i にすることができるならば Yes、できないならば No と出力せよ。


入力例 1

3
1 2 3
2
2 4
6
1 2 4 8 16 32
4
1 5 10 50

出力例 1

No
Yes
Yes
No
  • A,B,C からそれぞれ 1 個ずつ要素を選び和を 1 にすることはできません。
  • A,B,C からそれぞれ 1,2,2 を選ぶと和を 5 にすることができます。
  • A,B,C からそれぞれ 2,4,4 を選ぶと和を 10 にすることができます。
  • A,B,C からそれぞれ 1 個ずつ要素を選び和を 50 にすることはできません。

Score: 250 points

Problem Statement

You are given three sequences A=(A_1,\ldots,A_N), B=(B_1,\ldots,B_M), and C=(C_1,\ldots,C_L).

Additionally, a sequence X=(X_1,\ldots,X_Q) is given. For each i=1,\ldots,Q, solve the following problem:

Problem: Is it possible to select one element from each of A, B, and C so that their sum is X_i?

Constraints

  • 1 \leq N,M,L \leq 100
  • 0 \leq A_i, B_i ,C_i \leq 10^8
  • 1 \leq Q \leq 2\times 10^5
  • 0 \leq X_i \leq 3\times 10^8
  • All input values are integers.

Input

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

N
A_1 \ldots A_N
M
B_1 \ldots B_M
L 
C_1 \ldots C_L
Q
X_1 \ldots X_Q

Output

Print Q lines. The i-th line should contain Yes if it is possible to select one element from each of A, B, and C so that their sum is X_i, and No otherwise.


Sample Input 1

3
1 2 3
2
2 4
6
1 2 4 8 16 32
4
1 5 10 50

Sample Output 1

No
Yes
Yes
No
  • It is impossible to select one element from each of A, B, and C so that their sum is 1.
  • Selecting 1, 2, and 2 from A, B, and C, respectively, makes the sum 5.
  • Selecting 2, 4, and 4 from A, B, and C, respectively, makes the sum 10.
  • It is impossible to select one element from each of A, B, and C so that their sum is 50.
F - X drawing

Time Limit: 2 sec / Memory Limit: 1024 MiB

配点 : 300

問題文

上下左右に広がる N\times N のマス目があり、最初全てのマスは白く塗られています。このマス目の上から i 行目、左から j 列目のマスを (i,j) で表します。

高橋君は 1 以上 N 以下の整数 A, B を持っており、次のような操作を行います。

  • \max(1-A,1-B)\leq k\leq \min(N-A,N-B) をみたす全ての整数 k について、(A+k,B+k) を黒く塗る。
  • \max(1-A,B-N)\leq k\leq \min(N-A,B-1) をみたす全ての整数 k について、(A+k,B-k) を黒く塗る。

この操作を行った後のマス目について、P\leq i\leq Q かつ R\leq j\leq S をみたす各マス (i,j) がそれぞれ何色で塗られているか求めてください。

制約

  • 1 \leq N \leq 10^{18}
  • 1 \leq A \leq N
  • 1 \leq B \leq N
  • 1 \leq P \leq Q \leq N
  • 1 \leq R \leq S \leq N
  • (Q-P+1)\times(S-R+1)\leq 3\times 10^5
  • 入力は全て整数である。

入力

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

N A B
P Q R S

出力

Q-P+1 行出力せよ。
各行は #. のみからなる長さ S-R+1 の文字列であり、 i 行目の文字列の j 番目の文字が # であることは (P+i-1,R+j-1) が黒く塗られていることを、 . であることは (P+i-1,R+j-1) が白く塗られていることをさす。


入力例 1

5 3 2
1 5 1 5

出力例 1

...#.
#.#..
.#...
#.#..
...#.

1 つめの操作で (2,1), (3,2), (4,3), (5,4)4 マスが、 2 つめの操作で (4,1), (3,2), (2,3), (1,4)4 マスが黒く塗られます。
よって、P=1, Q=5, R=1, S=5 より、上のように出力します。


入力例 2

5 3 3
4 5 2 5

出力例 2

#.#.
...#

操作によって、 (1,1), (1,5), (2,2), (2,4), (3,3), (4,2), (4,4), (5,1), (5,5)9 マスが 黒く塗られます。
P=4, Q=5, R=2, S=5 より、上のように出力します。


入力例 3

1000000000000000000 999999999999999999 999999999999999999
999999999999999998 1000000000000000000 999999999999999998 1000000000000000000

出力例 3

#.#
.#.
#.#

入力が 32 bit 整数型に収まらないことがあることに注意してください。

Score : 300 points

Problem Statement

There is an N\times N grid with horizontal rows and vertical columns, where all squares are initially painted white. Let (i,j) denote the square at the i-th row and j-th column.

Takahashi has integers A and B, which are between 1 and N (inclusive). He will do the following operations.

  • For every integer k such that \max(1-A,1-B)\leq k\leq \min(N-A,N-B), paint (A+k,B+k) black.
  • For every integer k such that \max(1-A,B-N)\leq k\leq \min(N-A,B-1), paint (A+k,B-k) black.

In the grid after these operations, find the color of each square (i,j) such that P\leq i\leq Q and R\leq j\leq S.

Constraints

  • 1 \leq N \leq 10^{18}
  • 1 \leq A \leq N
  • 1 \leq B \leq N
  • 1 \leq P \leq Q \leq N
  • 1 \leq R \leq S \leq N
  • (Q-P+1)\times(S-R+1)\leq 3\times 10^5
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

N A B
P Q R S

Output

Print Q-P+1 lines.
Each line should contain a string of length S-R+1 consisting of # and .. The j-th character of the string in the i-th line should be # to represent that (P+i-1, R+j-1) is painted black, and . to represent that (P+i-1, R+j-1) is white.


Sample Input 1

5 3 2
1 5 1 5

Sample Output 1

...#.
#.#..
.#...
#.#..
...#.

The first operation paints the four squares (2,1), (3,2), (4,3), (5,4) black, and the second paints the four squares (4,1), (3,2), (2,3), (1,4) black.
Thus, the above output should be printed, since P=1, Q=5, R=1, S=5.


Sample Input 2

5 3 3
4 5 2 5

Sample Output 2

#.#.
...#

The operations paint the nine squares (1,1), (1,5), (2,2), (2,4), (3,3), (4,2), (4,4), (5,1), (5,5).
Thus, the above output should be printed, since P=4, Q=5, R=2, S=5.


Sample Input 3

1000000000000000000 999999999999999999 999999999999999999
999999999999999998 1000000000000000000 999999999999999998 1000000000000000000

Sample Output 3

#.#
.#.
#.#

Note that the input may not fit into a 32-bit integer type.

G - Count Interval

Time Limit: 2 sec / Memory Limit: 1024 MiB

配点 : 400

問題文

長さ N の数列 A=(A_1,A_2,\ldots,A_N) と、整数 K が与えられます。

A の連続部分列のうち、要素の和が K になるものはいくつありますか?
すなわち、以下の条件を全て満たす整数の組 (l,r) はいくつありますか?

  • 1\leq l\leq r\leq N
  • \displaystyle\sum_{i=l}^{r}A_i = K

制約

  • 1\leq N \leq 2\times 10^5
  • |A_i| \leq 10^9
  • |K| \leq 10^{15}
  • 入力に含まれる値は全て整数である

入力

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

N K
A_1 A_2 \ldots A_N

出力

答えを出力せよ。


入力例 1

6 5
8 -3 5 7 0 -4

出力例 1

3

(l,r)=(1,2),(3,3),(2,6)3 組が条件を満たします。


入力例 2

2 -1000000000000000
1000000000 -1000000000

出力例 2

0

条件を満たす (l,r) の組が 1 つも存在しないこともあります。

Score : 400 points

Problem Statement

Given is a sequence of length N: A=(A_1,A_2,\ldots,A_N), and an integer K.

How many of the contiguous subsequences of A have the sum of K?
In other words, how many pairs of integers (l,r) satisfy all of the conditions below?

  • 1\leq l\leq r\leq N
  • \displaystyle\sum_{i=l}^{r}A_i = K

Constraints

  • 1\leq N \leq 2\times 10^5
  • |A_i| \leq 10^9
  • |K| \leq 10^{15}
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

N K
A_1 A_2 \ldots A_N

Output

Print the answer.


Sample Input 1

6 5
8 -3 5 7 0 -4

Sample Output 1

3

(l,r)=(1,2),(3,3),(2,6) are the three pairs that satisfy the conditions.


Sample Input 2

2 -1000000000000000
1000000000 -1000000000

Sample Output 2

0

There may be no pair that satisfies the conditions.

H - Product Development

Time Limit: 4 sec / Memory Limit: 1024 MiB

配点 : 475

問題文

AtCoder 社はある商品の開発をしようとしています。この商品には K 個のパラメーターがあり、現段階ではすべてのパラメーターの値が 0 です。AtCoder 社の目標は、パラメーターの値を全て P 以上にすることです。

ここで、N 個の開発案があります。i(1 \le i \le N) 個目の開発案を実行すると、1 \le j \le K を満たす整数 j 全てに対して j 個目のパラメーターが A_{i,j} 上がりますが、この開発案を実行するにはコストが C_i かかります。

同じ開発案を 2 回以上実行することは出来ません。AtCoder 社が目標を達成出来るか判定し、出来る場合は目標を達成するのに必要なコストの総和の最小値を求めてください。

制約

  • 1 \le N \le 100
  • 1 \le K,P \le 5
  • 0 \le A_{i,j} \le P(1 \le i \le N,1 \le j \le K)
  • 1 \le C_i \le 10^9(1 \le i \le N)
  • 入力は全て整数

入力

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

N K P
C_1 A_{1,1} A_{1,2} \dots A_{1,K}
C_2 A_{2,1} A_{2,2} \dots A_{2,K}
\dots
C_N A_{N,1} A_{N,2} \dots A_{N,K}

出力

AtCoder 社が目標を達成出来るならば目標を達成するのに必要なコストの総和の最小値を、出来ないならば -1 を出力せよ。


入力例 1

4 3 5
5 3 0 2
3 1 2 3
3 2 4 0
1 0 1 4

出力例 1

9

1 個目と 3 個目と 4 個目の開発案を実行すると、それぞれのパラメーターが 3+2+0=5,0+4+1=5,2+0+4=6 で全て 5 以上となるため目標を達成できます。この場合コストの総和は 5 + 3 + 1 = 9 となります。

コストの総和 8 以下で目標を達成することは出来ません。よって答えは 9 です。


入力例 2

7 3 5
85 1 0 1
37 1 1 0
38 2 0 0
45 0 2 2
67 1 1 0
12 2 2 0
94 2 2 1

出力例 2

-1

どのようにしても目標を達成することは出来ません。よって -1 を出力します。

Score : 475 points

Problem Statement

AtCoder Inc. is planning to develop a product. The product has K parameters, whose values are currently all zero. The company aims to raise all parameter values to at least P.

There are N development plans. Executing the i-th development plan (1 \le i \le N) increases the value of the j-th parameter by A_{i,j} for every integer j such that 1 \le j \le K, at the cost of C_i.

A development plan cannot be executed more than once. Determine whether the company can achieve its goal, and if it can, find the minimum total cost required to achieve the goal.

Constraints

  • 1 \le N \le 100
  • 1 \le K,P \le 5
  • 0 \le A_{i,j} \le P(1 \le i \le N,1 \le j \le K)
  • 1 \le C_i \le 10^9(1 \le i \le N)
  • All input values are integers.

Input

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

N K P
C_1 A_{1,1} A_{1,2} \dots A_{1,K}
C_2 A_{2,1} A_{2,2} \dots A_{2,K}
\dots
C_N A_{N,1} A_{N,2} \dots A_{N,K}

Output

If AtCoder Inc. can achieve its goal, print the minimum total cost required to achieve the goal; otherwise, print -1.


Sample Input 1

4 3 5
5 3 0 2
3 1 2 3
3 2 4 0
1 0 1 4

Sample Output 1

9

If you execute the first, third, and fourth development plans, each parameter will be 3+2+0=5,0+4+1=5,2+0+4=6, all of which are at least 5, so the goal is achieved. The total cost in this case is 5 + 3 + 1 = 9.

It is impossible to achieve the goal at a total cost of 8 or less. Thus, the answer is 9.


Sample Input 2

7 3 5
85 1 0 1
37 1 1 0
38 2 0 0
45 0 2 2
67 1 1 0
12 2 2 0
94 2 2 1

Sample Output 2

-1

You cannot achieve the goal no matter what you do. Thus, print -1.

I - Black Jack

Time Limit: 2 sec / Memory Limit: 1024 MiB

配点 : 550

問題文

あなたとディーラーでゲームをします。 ゲームは 1 以上 D 以下の整数が等確率で出る D 面サイコロ、0 で初期化された変数 x,y を用いて以下のように行われます。

  • あなたはサイコロを振り、出た目を x に加算する操作を好きな回数行える。ここで、あなたは操作を行うたびに次の操作を行うかを選択できる。

  • その後、ディーラーは y < L を満たす限り、サイコロを振り、出た目を y に加算する操作を繰り返す。

  • x > N の場合あなたの負けである。そうでない場合、y > N または x>y のいずれかを満たす場合あなたの勝ちで、どちらも満たさない場合あなたの負けである。

あなたが勝率を最大化するように適切に行動する際、勝率を求めてください。

制約

  • 入力は全て整数
  • 1\leq L\leq N\leq 2\times 10^5
  • 1\leq D \leq N

入力

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

N L D

出力

答えを出力せよ。出力した値の真の値との絶対誤差または相対誤差が 10^{-6} 以下のとき正解と判定される。


入力例 1

3 2 2

出力例 1

0.468750000000000

x2 以下の場合操作を続けるという戦略が最適であることが証明できます。


入力例 2

200000 200000 200000

出力例 2

0.999986408692793

Score: 550 points

Problem Statement

You will play a game against a dealer. The game uses a D-sided die (dice) that shows an integer from 1 to D with equal probability, and two variables x and y initialized to 0. The game proceeds as follows:

  • You may perform the following operation any number of times: roll the die and add the result to x. You can choose whether to continue rolling or not after each roll.

  • Then, the dealer will repeat the following operation as long as y < L: roll the die and add the result to y.

  • If x > N, you lose. Otherwise, you win if y > N or x > y and lose if neither is satisfied.

Determine the probability of your winning when you act in a way that maximizes the probability of winning.

Constraints

  • All inputs are integers.
  • 1 \leq L \leq N \leq 2 \times 10^5
  • 1 \leq D \leq N

Input

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

N L D

Output

Print the answer. Your output will be considered correct if its absolute or relative error from the true value is at most 10^{-6}.


Sample Input 1

3 2 2

Sample Output 1

0.468750000000000

It can be proved that the optimal strategy is to continue rolling as long as x is not greater than 2.


Sample Input 2

200000 200000 200000

Sample Output 2

0.999986408692793