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 ...
随机推荐
- C#基础--多线程
一.微软早期操作系统中的问题 在早期的操作系统中,应用程序都是在同一个地址空间中运行的,每个程序的数据其它程序都是可见的,并且因为早期CPU是单内核 的所以所有的执行都是线性的.这就引出两个问题: 第 ...
- 单元测试工具Nunit
原文链接:http://blog.csdn.net/snowshinoy/article/details/6951352 调试 附加到: nunit-agent.exe进程:
- 在MySQL中使用explain查询SQL的执行计划
1.什么是MySQL执行计划 要对执行计划有个比较好的理解,需要先对MySQL的基础结构及查询基本原理有简单的了解. MySQL本身的功能架构分为三个部分,分别是 应用层.逻辑层.物理层,不只是MyS ...
- maven常见指令和插件
总结自:https://www.cnblogs.com/ysocean/p/7416307.html#_label1及 https://blog.csdn.net/zhaojianting/artic ...
- Android系统启动过程[典☆☆☆]
Android系统启动过程 首先Android框架架构图:(来自网上,我觉得这张图看起来很清晰) Linux内核启动之后就到Android Init进程,进而启动Android相关的服务和应用. 启动 ...
- Jquery12 Ajax
学习要点: 1.Ajax 概述 2.load()方法 3.$.get()和$.post() 4.$.getScript()和$.getJSON() 5.$.ajax()方法 6.表单序列化 Ajax ...
- HandyJSON第三方库的日常使用与错误记录
一.错误提示 1.更新Xcode10.2,Swift5.0出现错误提示 Undefined symbols for architecture x86_64: "_swift_getField ...
- svn的分支
svn的分支使用 新建一个项目的时候,选择建立自带trunk,branches和tags文件夹的. 其中trunk作为主开发. 有需要的时候,从trunk创建分支到对应的branches下面,新建分支 ...
- 从0开始 图论学习 邻接表 STL vector
邻接表表示 用vector实现 writer:pprp 代码如下: #include <bits/stdc++.h> using namespace std; const int maxn ...
- Mac Homebrew安装php56 到phpstorm过程问题汇总
Mac自带版本是php5.5,本来是用homebrew安装xdebug 命令:brew install php55-xdebug 但是安装之后使用phpstorm还是有问题.php -v 并没有显示有 ...