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 ...
随机推荐
- linux 安装 mysql
二进制安装mysql 1,下载安装包,使用国内站点速度会比较快,如清华站点https://mirrors.tuna.tsinghua.edu.cn 登陆linux系统后,使用wget 进行下载mysq ...
- UTF-8和GBK有什么区别
UTF-8和GBK有什么区别 2017年06月03日 18:10:43 阅读数:6516 GBK是在国家标准GB2312基础上扩容后兼容GB2312的标准(好像还不是国家标准).GBK编码专门用来解决 ...
- 盒子模型(Box Model)
盒子模型(Box Model) ■ 盒子模型——概念 在网页设计中常用的属性名:内容(content),填充(padding),边框(border),边界(margin),CSS 盒子模式都具备这些属 ...
- scrapy爬取58同城二手房问题与对策
测试环境: win10,单机爬取,scrapy1.5.0,python3.6.4,mongodb,Robo 3T 其他准备: 代理池:测试环境就没有用搭建的flask抓代理,因为我找到的几个免费网站有 ...
- 100-days: twenty-eight
Title: Lawrence Ferlinghetti's(劳伦斯·费林盖蒂) enduring San Francisco(旧金山) 劳伦斯·费林盖蒂心中的旧金山,历久弥新 费林盖蒂:美国垮掉的一 ...
- Codeforces Round #552 (Div. 3) D题
题目网站:http://codeforces.com/contest/1154/problem/D 题目大意:给出n个数(0或1),还有a , b, a是蓄电池容量,b是电池容量,数为1时蓄电池可以充 ...
- Codeforces Round #552 (Div. 3) B题
题目链接:http://codeforces.com/contest/1154/problem/B 题目大意:给出n个数,每个数都可以加上或减去这个一个数D,求对这n个数操作之后当所有数都相等时,D的 ...
- 微信小程序登录流程
小程序登录流程 参考 app.js需要做的 1,首先通过wx.login()拿到code,成功之后,发送数据,请求接口,把code发送给后端,换区openid,sessionKey,unionId,把 ...
- 使用Snappy将html或者url转成PDF文件
这是一个操作简单的html文件或者url转PDF的php库 Github地址 https://github.com/KnpLabs/snappy 安装: $ composer require knpl ...
- JavaScript 引用错误
在学习vue时 出现无法实现效果原始设置 <script src="js/lib/vue2.min.js"/><script src="js/lib/v ...