2014
01-26

# Knots

An even number N of strands are stuck through a wall. On one side of the wall, a girl ties N/2 knots between disjoint pairs of strands. On the other side of the wall, the girl’s groom-to-be also ties N/2 knots between disjoint pairs of strands. You are to find the probability that the knotted strands form one big loop (in which case the couple will be allowed to marry).

For example, suppose that N = 4 and you number the strands 1, 2, 3, 4. Also suppose that the girl has created the following pairs of strands by tying knots: {(1, 4), (2,3)}. Then the groom-to-be has two choices for tying the knots on his side: {(1,2), {3,4)} or {(1,3), (2,4)}.

The input file consists of one or more lines. Each line of the input file contains a positive even integer, less than or equal to 100. This integer represents the number of strands in the wall.

The input file consists of one or more lines. Each line of the input file contains a positive even integer, less than or equal to 100. This integer represents the number of strands in the wall.

4
20

0.66667
0.28377

//公式为：((n-2)*(n-4)*(n-6)*(n-8)*(n-10)*........)/((n-1)*(n-3)*(n-5)*(n-7)*(n-9)*........)
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int main()
{
int n;
while(scanf("%d",&n)!=EOF)
{
int i;
double ans=1.0;
for(i=2;i<=n-2;i+=2)
ans*=(double)i/(double)(i+1);
printf("%.5lf/n",ans);
}
return 0;
}

1. 小米手机性价比的确高，但你叫我多花几百块钱买什么黄牛货，那我觉得我真是有病了。在设计方面魅族≈锤子＞小米，不过在做工方面这三家是半斤八两，小米还偏差点，因为没有设计加成。