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 ...
随机推荐
- sgu 103 Traffic Lights 解题报告及测试数据
103. Traffic Lights Time limit per test: 0.25 second(s) Memory limit: 4096 kilobytes 题解: 1.其实就是求两点间的 ...
- Ubuntu&Linux系统出现文件系统只读Read-only file system 的快速解决方法
问题描述: 周末运行盘平台服务程序,周一来操作系统卡顿,主进程已退出,重启进程时提示Read-only file system:新建目录和其他chmod -R等等操作都提示Read-only file ...
- ThinkPHP语法总结
1, $data存放实体: $data['title'] = I('post.title'); // 标题 $data['content'] = I('post.content'); // 正文 $d ...
- [HNOI2019]校园旅行(构造+生成树+动规)
题目 [HNOI2019]校园旅行 做法 最朴素的做法就是点对扩展\(O(m^2)\) 发现\(n\)比较小,我们是否能从\(n\)下手减少边数呢?是肯定的 单独看一个颜色的联通块,如果是二分图,我们 ...
- C++类中成员变量的初始化总结(转帖)
本文转自:C++类中成员变量的初始化总结 1. 普通的变量: 一般不考虑啥效率的情况下 可以在构造函数中进行赋值.考虑一下效率的可以再构造函数的初始化列表中进行. 1 class CA ...
- JavaScript浮点运算,小数点精度
math.js JavaScript浮点运算,小数点精度 // JavaScript Document //数学函数 // 浮点数加法运算 function floatAdd(arg1, arg2) ...
- 如何确保C#的应用程序只被打开一次
http://stackoverflow.com/questions/184084/how-to-force-c-sharp-net-app-to-run-only-one-instance-in-w ...
- mybatis中的懒加载
知识点:mybatis中的懒加载的使用 参考:https://www.cnblogs.com/ysocean/p/7336945.html?utm_source=debugrun&utm_me ...
- centos redis 3.2.11 安装与配置
centos 7 下载解压 wget http://download.redis.io/releases/redis-3.2.11.tar.gz tar xzf redis-3.2.11.tar.gz ...
- jsp选项卡导航实现——模板
效果 刚进来页面的样子 在第二个选项卡上方时 点击后 离开 同样第三个 点击 移走鼠标 代码 <%@ page contentType="text/html;charset=UTF-8 ...