问题 I: Kid and Ants

时间限制: 1 Sec  内存限制: 128 MB
提交: 42  解决: 33
[提交][状态][讨论版]

题目描述

Kid likes interest question,although he don’t like ants so much.

Assume there is a infinite long stick whose direction is from East to West. In addition, there are n

ants on the stick and their original orientation is arbitrary(East or West).Then from a moment,all

the ants will climb on the stick at the same speed toward their original orientation.Once two ants

touch each other, they will change their orientation and go up climbing.(May be some ants will

never meet other ants).So now Kid’s task is to calculate the mathematical expectation of the meets

between ants.

输入

There are multiple cases.

For each case,there is a integer n.(1<=n<=10^9)

输出

For each case,just print the mathematical expectation(retain three decimals)

样例输入

2
10

样例输出

0.250
11.250

提示

When n=2,there 4 cases(E indicates the orientation of the ant is East and W is West)

(left is East and right is West)

{E,E},{E,W},{W,E},{W,W}

And the number of meets is 0,0,1,0, so the mathematical expectation is (0+0+1+0)/4=0.250.

随便取两只蚂蚁,方案数n*(n-1)/2,对这两只蚂蚁有四种状态,一种碰撞
 
#include <cstdio>
using namespace std;
int main(){
int n;
while(scanf("%lf",&n)==1&&n){
printf("%.3f\n",(double)n*(n-1)/8.0);
}
return 0;
}

  

 

NEU 1497 Kid and Ants 思路 难度:0的更多相关文章

  1. POJ 1083 Moving Tables 思路 难度:0

    http://poj.org/problem?id=1083 这道题题意是有若干段线段,每次要求线段不重叠地取,问最少取多少次. 因为这些线段都是必须取的,所以需要让空隙最小 思路: 循环直到线段全部 ...

  2. NEU 1496 Planar map 计算几何,点到线段距离 难度:0

    问题 H: Planar map 时间限制: 1 Sec  内存限制: 128 MB提交: 24  解决: 22[提交][状态][讨论版] 题目描述 Tigher has work for a lon ...

  3. NEU 1495 a interesting game 大数 难度:1

    问题 G: a interesting game 时间限制: 1 Sec  内存限制: 128 MB提交: 29  解决: 10[提交][状态][讨论版] 题目描述 One day,Kid is in ...

  4. UVa 10382 - Watering Grass 贪心,水题,爆int 难度: 0

    题目 https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&a ...

  5. UVa 10970 - Big Chocolate 水题 难度: 0

    题目 https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&a ...

  6. Uva LA 3902 - Network 树形DP 难度: 0

    题目 https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_pr ...

  7. Uva 12124 Uva Live 3971 - Assemble 二分, 判断器, g++不用map.size() 难度:0

    题目 https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_pr ...

  8. UVa 11384 - Help is needed for Dexter 分析, 树状数组 难度: 0

    题目 https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&a ...

  9. UVa 11210 - Chinese Mahjong 模拟, 枚举 难度: 0

    题目 https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&a ...

随机推荐

  1. 百度nlp实习生转岗(猝)

    一面: 大部分是问项目相关的.只记住了几个关键的问题. 1.手写快排 2.生成模型与判别模型的区别 分类问题:2种形式: F(x)=y p(y|x) 生成模型:由数据学习联合分布概率p(x,y),然后 ...

  2. IOS开发如何入门

    说到 iOS 开发,自己学得也很浅.不过至少独立一人完成了一个应用的开发到项目上线整个过程.分享一下自己的建议和想法. 首先建议阅读 Start Developing iOS Apps Today,你 ...

  3. openJudge C17K:Lying Island

    地址:http://poj.openjudge.cn/practice/C17K/ 题目: C17K:Lying Island 查看 提交 统计 提问 总时间限制:  2000ms 内存限制:  26 ...

  4. TOSCA自动化测试工具--建立测试用例

    1.测试链接 demowebshop.tricentis.com 测试login 2.检查元素 3.Modules模块,建立自己的文件夹,右键Scan Application , Desktop 4. ...

  5. 分布式存储系统 Ceph

    你了解Ceph吗? Ceph是一种分布式存储系统,它可以将多台服务器组成一个超大集群,把这些机器中的磁盘资源整合到一块儿,形成一个大的资源池(PB级别),然后按需分配给应用使用. 那么你知道Ceph的 ...

  6. laravel 环境配置

    一.composer 安装 1.确定为最新版本的PHP 2.进入Composer官网下载页面,在页面最下方Manual Download区域选择需要的版本下载. 3.将下载的composer.phar ...

  7. win32api win32gui win32con 窗口句柄 发送消息 常用方法

    Pywin32是一个Python库,为python提供访问Windows API的扩展,提供了齐全的windows常量.接口.线程以及COM机制等等. 1.通过类名和标题查找窗口句柄,并获得窗口位置和 ...

  8. NUMA架构的优缺点

    numa把一台计算机分成多个节点(node),每个节点内部拥有多个CPU,节点内部使用共有的内存控制器,节点之间是通过互联模块进行连接和信息交互.因此节点的所有内存对于本节点所有的CPU都是等同的,对 ...

  9. Sql调试

    1 ,调试 普通sql语句, 直接  F11 2,调试存储过程  F11->F10执行到 存储过程语句 在按F11 跳转进入到Sql存储过程内

  10. Linux学习笔记之Linux启动引导过程

    早期时,启动一台计算机意味着要给计算机喂一条包含引导程序的纸带,或者手工使用前端面板地址/数据/控制开关来加载引导程序.尽管目前的计算机已经装备了很多工具来简化引导过程,但是这一切并没有对整个过程进行 ...