In fact, after a very simple to understand, but just started really hard to think .. When D [a] [b] represents a remaining sheets A Class B Class tickets and tickets Zhang b, the same last two tickets probability
At this time, the first person then queued choose to take only two Class A or Class B votes votes
Of course, the possibility is obtained a coin toss one half, so that the d [i-1] [j] (who took the first current class A votes), and d [i] [j-1] (the current first person class B took votes) half and one-half
In this case the code is very simple. . . .
#include<stdio.h> #include<iostream> using namespace std; double d[1500][1500]; int main() { int n,i,j; scanf("%d",&n); n/=2; for (i=2;i<=n;i++) { d[i][0]=d[0][i]=1; } for (i=1;i<=n;i++) { for (j=1;j<=n;j++) { d[i][j]=(d[i-1][j]+d[i][j-1])*0.5; } } printf ("%.4lf",d[n][n]); return 0; }