http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=3904
题目大意:n个人n个位置,第一个人随便坐,以后的人若位置被占就随便坐否则坐自己的位置,求nth的人位置被占的概率。
解题思路:简单笔算后发现概率均为1/2。
代码:
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#define MAXN 0
#define INF 0x7fffffff
#define eps 1e-10
#define MAX(x,y) ((x)>(y)? (x):(y))
#define MIN(x,y) ((x)<(y)? (x):(y))
#define MEM(a) (memset((a),0,sizeof(a)))
#define FRE freopen("input.txt","r",stdin)
using namespace std;
int main()
{
int n;
while(scanf("%d",&n) && n)
printf("1/2\n");
return 0;
}