NEU 1497 Kid and Ants 思路 难度:0
问题 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.
#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的更多相关文章
- POJ 1083 Moving Tables 思路 难度:0
http://poj.org/problem?id=1083 这道题题意是有若干段线段,每次要求线段不重叠地取,问最少取多少次. 因为这些线段都是必须取的,所以需要让空隙最小 思路: 循环直到线段全部 ...
- NEU 1496 Planar map 计算几何,点到线段距离 难度:0
问题 H: Planar map 时间限制: 1 Sec 内存限制: 128 MB提交: 24 解决: 22[提交][状态][讨论版] 题目描述 Tigher has work for a lon ...
- NEU 1495 a interesting game 大数 难度:1
问题 G: a interesting game 时间限制: 1 Sec 内存限制: 128 MB提交: 29 解决: 10[提交][状态][讨论版] 题目描述 One day,Kid is in ...
- UVa 10382 - Watering Grass 贪心,水题,爆int 难度: 0
题目 https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&a ...
- UVa 10970 - Big Chocolate 水题 难度: 0
题目 https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&a ...
- Uva LA 3902 - Network 树形DP 难度: 0
题目 https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_pr ...
- 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 ...
- UVa 11384 - Help is needed for Dexter 分析, 树状数组 难度: 0
题目 https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&a ...
- UVa 11210 - Chinese Mahjong 模拟, 枚举 难度: 0
题目 https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&a ...
随机推荐
- 企业规范化管理系统iClap前生后世全解析
iClap是一个产品管理系统,专注于为移动互联网企业提供企业规范化解决方案,改变传统的产品管理模式,实现产品管理场景化.APP.甚至原型图.效果图都可以直接进行批注和任务的协作,实时将你要修改的内容或 ...
- BZOJ 1316: 树上的询问
挺裸的点分治 刚开始想用map水过去,然后做p次点分治,然后T到自闭 最后发现可以sort一遍,然后去重,记录每个数出现的次数,这样就可以双指针,不会漏掉了 #include <bits/std ...
- 怎么解决teamviewer检测商业用途无法使用的问题
https://jingyan.baidu.com/article/d5c4b52be51162da560dc517.html
- javascript中常用函数汇总
js中函数很多,在实际项目开发中,函数的应用可以很大程度上简化我们的代码,所以在此记下开发中js中常用的函数,增强记忆. 1.isNaN(X):函数用于检查其参数是否是非数字值. 如果 x 是特殊的非 ...
- ThreadLocal的设计理念与作用
转自:http://www.iteye.com/topic/103804 首先,ThreadLocal 不是用来解决共享对象的多线程访问问题的,一般情况下,通过ThreadLocal.set() 到线 ...
- [转]将oracle数据库的编码变成utf-8
1.改客户端字符集:通过WINDOWS的运行菜单运行Regedit,修改注册表 Start -> Run -> Rededit <-| Under registry Editor - ...
- java压缩多个文件
首先创建一个工具类,定义好接口,这里的参数1:fileList:多个文件的path+name2: zipFileName:压缩后的文件名 下面是代码,注释已经很详细了 public class ZIP ...
- 20145322 《Java程序设计》第6周学习总结
20145322 <Java程序设计>第6周学习总结 教材学习内容总结 第十章 10.1.1 串流设计的概念 Java将输入/输出抽象化为串流,数据有来源及目的地,衔接两者的是串流对象. ...
- hdu4310 - Hero - 简单的贪心
2017-08-26 15:25:22 writer:pprp 题意描述: • 1 VS n对战,回合制(你打他们一下,需要受到他们所有存活人的攻击)• 你的血量无上限,攻击力为1• 对手血量及攻击 ...
- 用gitolite搭建git server
在Ubuntu上测试安装一下git server,为后面项目的代码管理做准备.记录流水账如下, 中间关于git 命令的使用说明不做过多解释,需要了解的请google或者直接git help: 我用到了 ...