思路:这个题居然高数老师说过...它的公式其实就是x*f(x)的积分/f(x)的积分,f(x)=(r^2-x^2)^(n-1)/2,然后推推就出来了

#include<bits/stdc++.h>
using namespace std;
const int maxn = 2*1e5+7;
#define LL long long
#define pi acos(-1.0)
double si[maxn];void init()
{si[0]=1;si[1]=1;for(int i = 2;i<maxn;i++)si[i]=si[i-2]*(i-1)/i;
}
int main()
{init();int r,n;while(scanf("%d%d",&n,&r)!=EOF){if(n&1)printf("%.10lf\n",1.0*r/(n+1)/si[n]);elseprintf("%.10lf\n",1.0*r/(n+1)/(si[n]*pi/2));}
}

Description

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(x 1, x 2, ... , x n) chosen uniformly from possible positions satisfying x i >= 0 and x 1 2 + x 2 2 + ... <= R 2
Assume the expectation of his coordinate after his first step is (y 1, y 2, ... , y n). He wants to know the minimum y i .

Input

There are several (about 100,000) test cases, please process till EOF. 
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 * 10 5, R <= 10 5).

Output

For each test case, print a real number representing the answer to the question above. 
Your answer is considered correct if the difference between your answer and the correct one is less than 10 -6.

Sample Input

2 1

Sample Output

0.4244131816

HDU 4808 Drunk(数学)相关推荐

  1. HDU 4808 Drunk

    题意:给定一个n维欧几里德空间中的一个n维向量(x1,x2,..,xn),xi>=0,sigma(xi^2)<=R^2.问xi最小值的期望. 解法:注意到空间球体的强对称性,即求x方向上的 ...

  2. HDU 4808 数学 期望 积分

    HDU 4808 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=4808 题意: 在一个多维空间中,一个人从原点迈出一步,这步最多R那么长.问其中一维 ...

  3. HDU 5914 Triangle 数学找规律

    Triangle 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5914 Description Mr. Frog has n sticks, who ...

  4. Hdu 5339 Untitled (数学思维)

    题意:给一个数a和n个数b1,b2,...,bn. 从n个数中选择一些数重新排列成c1,c2,...,cm使得a%c1%c2%...%cm=0. 如果能选出则输出最少需要几个数,否则输出-1. 分析: ...

  5. HDU 5976 Detachment(数学+结论)

    原题地址:http://acm.hdu.edu.cn/showproblem.php?pid=5976 参考博客:https://blog.csdn.net/qq_34374664/article/d ...

  6. hdu 1593(数学)

    转载标记处:http://www.xuebuyuan.com/2131627.html 往相反的方面跑,但是,最理想的初始位置并不是圆点和圆上的某一点,应该还有更理想的初始逃跑状态.这里有一点需要注意 ...

  7. Circle HDU - 6550 (数学)

    在半径为 1 的圆上有 n 个点,它们也是圆的 n 等分点,将每个相邻的 n 等分点相连,组成了一个正 n边形,现在你可以在圆上再增加一个点,使得新的 n + 1 边形的面积最大,请输出最大面积. I ...

  8. Function HDU - 6546 (数学,贪心)

    wls 有 n 个二次函数 Fi(x) = aix2 + bix + ci (1 ≤ i ≤ n). 现在他想在∑ni=1xi = m 且 x 为正整数的条件下求∑ni=1Fi(xi)的最小值. 请求 ...

  9. B - Cube HDU - 1220 (数学计数)

    题意:一个边长为N的正方体,切割成N*N*N个单位正方体,问有多少对正方体之间有0个,2个公共点. 思路:因为正方体之间出现公共点的情况有0,2,4. 那么直接正面求,肯定不好求,那么先求出有4个公共 ...

最新文章

  1. Learn Jenkins the hard way (0) - Jenkins的罪与罚
  2. Nodejs进阶:express+session实现简易身份认证
  3. CTFshow php特性 web114
  4. Html 教程 (4) <head>
  5. nginx php fpm sock_nginx使用sock方式调用php-fpm
  6. CSS布局奇淫技巧之--各种居中
  7. Python学习秘籍 这些窍门就连老司机都不一定知道 值得学习
  8. 多项式的链式存储方案
  9. 疑似OPPO Reno6系列新机通过工信部认证:配备6.43英寸屏 机身仅7.9mm
  10. AES加密例子(python和php版本)
  11. Ubuntu开启Mongodb 外网访问
  12. 铁芯用matlab怎么仿真,Simulink的BLDC建模与仿真
  13. 2345浏览器网址_清理流氓网站2345.com劫持浏览器
  14. Spring AOP失效之谜
  15. 获取 app 签名的方式汇总
  16. led伏安特性实验误差分析_大学物理实验伏安特性曲线的误差分析以及小结要怎么写,谢谢^ω^...
  17. python读取文件并替换字段_python 读取文件并替换字段的实例
  18. html创建站点文件夹,构建及访问Web站点
  19. linux格式化fat的命令,Linux磁盘格式化命令详解
  20. xv6进程切换-swtch函数

热门文章

  1. 小白理解——封装继承多态
  2. js下载文件及前端使用a标签下载文件download属性失效问题
  3. 51单片机简易秒表的设计(含源代码、编译过的 HEX 文件以及仿真图)
  4. vue2实践揭秘pdf_Vue2实践揭秘
  5. wordpress后台管理(八)外观-小工具:管理常用的DUX主题附带的小工具或wordpress自带的小工具
  6. 使用Everest和ACPI Patcher轻松生成dsdt.aml
  7. 数据挖掘中的数据分类
  8. CAD绘制复杂轴承图形
  9. Jmeter和jdk的下载和安装
  10. 约吗?有料有趣的物联网大会