HDU5810 Balls and Boxes
Balls and Boxes
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 797 Accepted Submission(s): 526
the statistical variance V as
where Xi is
the number of balls in the ith box, and X¯ is
the average number of balls in a box.
Your task is to find out the expected value of V.
The input is terminated by n = m = 0.
2 2
0 0
1/2
In the second sample, there are four possible outcomes, two outcomes with V = 0 and two outcomes with V = 1.
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <cmath>
#include <set>
#include <stack>
#include <queue>
#include <vector>
#include <bitset>
#include <functional> using namespace std; #define LL long long
const int INF = 0x3f3f3f3f; LL n,m; LL gcd(LL x,LL y)
{
return x?gcd(y%x,x):y;
} int main()
{
while(~scanf("%lld%lld",&n,&m)&&(n+m))
{
if(m==1) {printf("0/1\n");continue;}
n=(m-1)*n;
m=m*m;
printf("%lld/%lld\n",n/gcd(n,m),m/gcd(n,m));
}
return 0;
}
HDU5810 Balls and Boxes的更多相关文章
- hdu-5810 Balls and Boxes(概率期望)
题目链接: Balls and Boxes Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/O ...
- HDU 5810 Balls and Boxes(盒子与球)
Balls and Boxes(盒子与球) Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/O ...
- Codeforces Round #158 (Div. 2) C. Balls and Boxes 模拟
C. Balls and Boxes time limit per test 1 second memory limit per test 256 megabytes input standard i ...
- HDU 5810 Balls and Boxes (找规律)
Balls and Boxes 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5810 Description Mr. Chopsticks is i ...
- HDU 5810 Balls and Boxes 数学
Balls and Boxes 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5810 Description Mr. Chopsticks is i ...
- Codeforces 260C - Balls and Boxes
260C - Balls and Boxes 思路:模拟.在x前面找到最小值,如果没有,从0跳到n,继续找到最小值,边找最小值路过的点边减1.然后所有值都减去最小值,最小值那个点加上减去的值. 找到x ...
- hdu 5810 Balls and Boxes 二项分布
Balls and Boxes Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)T ...
- 2016 多校联赛7 Balls and Boxes(概率期望)
Mr. Chopsticks is interested in random phenomena, and he conducts an experiment to study randomness. ...
- 【HDU 5810多校】Balls and Boxes(打表/数学)
1.打表找规律,下面是打表程序: #include <iostream> #include <cstdio> #define ll long long #define N 10 ...
随机推荐
- RSA总结
面试问到RSA了,大脑有些空白,查漏补缺吧 什么是RSA RSA算法是一种非对称的加密算法,所谓非对称,就是指算法需要一对密钥,使用其中一个加密,则需要另一个才能解密.密钥分为公钥和私钥,私钥自己保存 ...
- NetCore+MySql+EF 数据库生成实体模型
NetCore版本 2.1 1.点击“工具”->“NuGet包管理器”->“程序包管理器控制台” 分别安装以下几个包 Mysql 版本: MySql.Data.EntityFrame ...
- LeetCode至 少有 1 位重复的数字
给定正整数 N,返回小于等于 N 且具有至少 1 位重复数字的正整数. 示例 1: 输入:20 输出:1 解释:具有至少 1 位重复数字的正数(<= 20)只有 11 . 示例 2: 输入:10 ...
- Getting.Started.with.Unity.2018.3rd.Edition
Getting Started with Unity 2018 - Third Edition: A Beginner's Guide to 2D and 3D game development wi ...
- css与dom的渲染与解析
js阻塞文档渲染与解析那么css呢? 结论一.css:阻塞渲染,不阻塞dom解析 <head> <script> document.addEventListener('DOMC ...
- 大数据学习(一)-------- HDFS
需要精通java开发,有一定linux基础. 1.简介 大数据就是对海量数据进行数据挖掘. 已经有了很多框架方便使用,常用的有hadoop,storm,spark,flink等,辅助框架hive,ka ...
- Redis分布式缓存
Redis 主 slave 数据库优化-- 加inex, 分区 JVM调优--参数设置,比如偏向于计算的如何设置? 线程池:queue放满了之后,有什么方式能让他不拒绝掉?blockqueue就等在那 ...
- Zookeeper使用--命令行
一.前言 在学习了Zookeeper相关的理论知识后,下面接着学习对Zookeeper的相关操作. 二.Zookeeper部署 Zookeeper的部署相对来说还是比较简单. Zookeeper有三种 ...
- CentOS7 常用设置
安装配置 0.Centos7 优盘U盘安装以及解决安装时引导错误 1.CentOS7开启网卡,设置开机启用网卡 2.CentOS7 修改静态IP地址 3.CentOS7 下使用root免密码输入自动登 ...
- Tigase 发送消息的流程源码分析
XMPP 的<message/>节是使用基本的”push”方法来从一个地方到另一个地方得到消息.因为消息通常是不告知的,它们是一种”fire-and-forget”(发射后自寻目的)的机制 ...