2015
09-18

# Drunk

Jenny is seriously drunk. He feels as if he is in an N-dimension Euclidean space, wandering aimlessly. In each step, he walks toward some direction and the “length” of each step will not exceed R. Technically speaking, Jenny is initially located at the origin of the N-dimension Euclidean space. Each step can be represented by a random N-dimension vector(x1, x2, … , xn) chosen uniformly from possible positions satisfying xi >= 0 and x12 + x22 + … <= R2.
Assume the expectation of his coordinate after his first step is (y1, y2, … , yn). He wants to know the minimum yi .

Each test case, only one line contains two integers N and R, representing the dimension of the space and the length limit of each step.(1 <= n <= 2 * 105, R <= 105).

Each test case, only one line contains two integers N and R, representing the dimension of the space and the length limit of each step.(1 <= n <= 2 * 105, R <= 105).

2 1

0.4244131816

题意:给定一个n维欧几里德空间中的一个n维向量(x1,x2,..,xn),xi>=0,sigma(xi^2)<=R^2.问xi最小值的期望.

#include <cstdio>
#include <cmath>
const int MAXN = 200000 + 5;

double t[MAXN];

int main()
{
t[0] = acos(-1) / 2., t[1] = 1.;
for (int i = 2; i < MAXN; ++ i) {
t[i] = t[i - 2] * (i - 1) / i;
}
int n, R;
while (scanf("%d%d", &n, &R) == 2) {
double res = .5 * t[n + 1] * R / t[2];
printf("%.10lf\n", res);
}
return 0;
}