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 ...
随机推荐
- 2017 Multi-University Training Contest - Team 4 hdu6069 Counting Divisors
地址:http://acm.split.hdu.edu.cn/showproblem.php?pid=6069 题目: Counting Divisors Time Limit: 10000/5000 ...
- 记一次ZOOKEEPER集群超时问题分析
CDH安装的ZK,三个节点,基本都是默认配置,一直用得正常,今天出现问题,客户端连接超时6倍时长,默认最大会话超时时间是一分钟.原因分析:1.首先要确认网络正确.确认时钟同步.2.查看现有的配置,基本 ...
- Python笔记 #02# Inner workings of lists
源:DataCamp datacamp 的 DAILY PRACTICE + 日常收集. List of lists Subset and conquer Slicing and dicing Li ...
- 高可用Mysql架构_Mycat集群部署(HAProxy + 两台Mycat+Mysql双主双从)
既然大家都知道了Mysql分布式在大型网站架构中的作用,在这里就不再阐述.本片博客文章是基于我曾经搭建过的一个Mysql集群基础上实现的,实现过双主热备.读写分离.分库分表. 博客链接:http:// ...
- 20145335《java程序设计》第5次实验报告
20145335郝昊实验五 java网络编程及安全 实验内容 1.掌握Socket程序的编写: 2.掌握密码技术的使用: 3.设计安全传输系统. 实验步骤 本次实验我的结对编程对象是20145307陈 ...
- Ubuntu 12.04下安装QQ 2012 Beta3
Ubuntu 12.04下安装QQ 2012 Beta3 由于wine的发展非常迅速.现在网上的利用老版本的wine来安装QQ2012的教程已经有些过时了.实际上操作起来非常简单: 第一步:Ctr ...
- wamp 环境下配置多台虚拟主机
首先启动wamp,成功之后,单击图标,找到Apache服务器下的 httpd.conf ,直接打开 按下Ctrl+F键,在搜索框中搜索 Virtual hosts, 搜寻结果如下图: 3. 然后打开w ...
- 百度开源分布式id生成器uid-generator源码剖析
百度uid-generator源码 https://github.com/baidu/uid-generator snowflake算法 uid-generator是基于Twitter开源的snowf ...
- Commons Configuration之二基本特性和AbstractConfiguration
Configuration接口定义一大堆方法.一切从头开始实现这些方法非常困难.因为AbstractConfiguration类存在.该类在Commons Configuration中充当大多数Con ...
- 【线性判别】Fisher线性判别(转)
今天读paper遇到了Fisher线性判别的变体, 所以来学习一下, 所以到时候一定要把PRMl刷一遍呀 以下两篇论文一起阅读比较好: 论文1: https://blog.csdn.net/Rainb ...