题目描述
There are n ants on a polygon. The polygon has n edges and every ant is on a corner at first. Than the ants start to move on edges. A corner connects two edges, so the ants choose to move on one edge of the two randomly. If two ants move on a same edge , they will be angry. Give you the number n. Calculate the probability that there exists some ants angry, after their first choice.
输入
Multiple cases. Every case takes a line with the number n. (3 <= n <= 15)
输出
A case a line.Print the probability, with exactly 6 digits after the decimal point.
样例输入
4
样例输出
0.875000
提示
#include<stdio.h>
#include<math.h>
int main()
{
int n,i;
while(scanf("%d",&n)!=EOF)
printf("%.6f\n",1-pow(0.5,n-1));
return 0;
}