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 ...
随机推荐
- 使用C编程语言实现AVL树
本文将介绍AVL树及其插入.删除操作,最后使用C编程语言实现基于平衡因子(balance factor)的AVL树. 什么是AVL树? AVL树(AVL tree)是前苏联计算机科学家Adelson- ...
- git命令行获取某分支代码
参考https://www.cnblogs.com/nylcy/p/6569284.html git clone -b branch1 http://xxx.xx.xxx... git clone - ...
- Jboss项目部署出现java.lang.UnsupportedClassVersionError 问题的解决方法
出现java.lang.UnsupportedClassVersionError 错误的原因,是因为我们使用高版本的JDK编译的Java class文件试图在较低版本的JVM上运行,所报的错误. 解决 ...
- airTest 应用到项目并优化
之前已经介绍了airTest的原理,该文主要指引大家能够将airTest框架应用到具体的测试项目当中去. 首先要考虑的是: 1. 你是用airTest 去做什么自动化 (android, ios, w ...
- rror: too many values to unpack
方法返回值
- [BZOJ2252]矩阵距离(BFS)
题意 输入矩阵m行n列(m<=500,n<=500),只含0.1,输出离每个元素距离最近的1的距离,其中距离定义为D(aij,akl)=abs(i-k)+abs(j-l). 示例: 输入: ...
- paloalto防火墙注册
一.创建账户 1.注册网站: https://support.paloaltonetworks.com/Support/Index 2.单击 Activate My Account 3.输入 Your ...
- commandjs、AMD、CMD之间的故事
commandjs:同步加载,只运行一次,后面使用第一次加载时运行的结果(存于缓存中),用于服务器 AMD:define(id ?,dependencies ?,factory) 异步加载,用于浏览器 ...
- itchat 报错 OSError: [WinError -2147221003] 找不到应用程序: 'QR.png'
OSError: [WinError -2147221003] 找不到应用程序: 'QR.png' 原因: 缺少在windows 下相关处理方法 解决方法:找到你运行环境C:\Python36\L ...
- 一篇文章说清楚mysql索引
索引是什么? 索引是为了加速对表中数据行的检索而创建的一种分散的数据存储结构 为什么要使用索引? 索引能极大的减少数据存储引擎需要需要扫描的数据量: 索引能够把随机IO变为数序IO: 索引能够帮助我们 ...