#P1302. Zju2271 Chance to Encounter a Girl

Zju2271 Chance to Encounter a Girl

题目翻译

很久很久以前,有一个小而美丽的国家,里面住着一个非常聪明的女孩。这个女孩对旅行很感兴趣,每天她都从一个城镇旅行到另一个城镇。她的方向感很差,她总是忘记自己来自的那条路,随便选择一个乡村小镇继续前进。她从未出过国。

你,一个很酷的人,用时光机回到了过去,穿越了整个国家。如果你能遇到那个女孩,爱情就会发生,故事就会有一个幸福的结局。

那么,圆满结局的概率是多少呢?

这个国家由n×nn\times n块(4n1004\leq n \leq 100nn为偶数),每个街区是一个城镇。每天,女孩可以向上、向左、向下或向右移动到邻近的城镇,而你必须向右移动,直到你遇到女孩或离开这个国家。

假设左下角的城镇是(0,0)(0,0)。最初,女孩在小镇(n2n2)(\dfrac{n}{2}, \dfrac{n}{2}),而你在(1n2)(-1,\dfrac{n}{2})

下图是国家(3×3)(3 \times 3)的样本,“G”是女孩的初始位置,“Y”是你的。

  +-+-+-+
  | | | |
+-+-+-+-+
|Y| |G| |
+-+-+-+-+
  | | | |
  +-+-+-+

题目描述

Long long ago, there was a small but beautiful country, in which lived a very smart girl. The girl was very interested in travelling, every day she travelled from one town to another. Her sense of direction is so bad that she always forgot the road which she had came from and randomly chose a town in the country to move on. She never went out of the country.

You, a very cool man, go back to the past using a time machine and travelled through the country. If you could meet the girl, love would happen and the story would have a happy end.

So, what's the probability of a happy end?

The country consists of n×nn\times n blocks (n=2×k1;k=2,...,50)(n = 2\times k - 1; k = 2,...,50), each block is a town. Every day, the girl can move up, left, down or right to a neighbor town, and you, the cool man, must move right until you meet the girl or get outside the country.

Assume the left bottom town is (0,0)(0, 0). Initially, the girl is in the town (n2,n2)(\dfrac{n}{2}, \dfrac{n}{2}) and you are in (1,n2)(-1,\dfrac{n}{2}).

The following figure is a sample of country (3×3)(3 \times 3), G is the girl's inital position and Y is yours.

+-+-+-+
        | | | |
      +-+-+-+-+
      |Y| |G| |
      +-+-+-+-+
        | | | |
        +-+-+-+

输入格式

There are multiple test cases(less than 3030). For each case there is only one line containing an integer n(n=2×k1;1<k50)n (n = 2 \times k - 1; 1 < k \leq 50). Proceed until the end of file.

输出格式

For each test case you should print the possibility of a happy end. Round to four decimal digits.

样例输入

3

样例输出

0.6667

提示

本题有多组数据,请做到文件底结束。