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 ...
随机推荐
- React Native的学习资源网址
react官方文档(英文): https://facebook.github.io/react/docs/getting-started.html react中文社区(内部有视频教程等): htt ...
- <web-view>中JSSDK
如果只是使用wx.miniProgram.navigateTo这种导航的接口,jssdk可以不用做配置,引用js后直接使用就行,如果chooseImage这种,就需要获取配置了,步骤如下: 先在后端通 ...
- 大数据实操2 - hadoop集群访问——Hadoop客户端访问、Java API访问
上一篇中介绍了hadoop集群搭建方式,本文介绍集群的访问.集群的访问方式有两种:hadoop客户端访问,Java API访问. 一.集群客户端访问 Hadoop采用C/S架构,可以通过客户端对集群进 ...
- 验证当前启动APP的Package 和 Activity
1. 打开手机USB 调试开关 2. 执行: adb devices 3.启动你的测试APP (如手机QQ) 4.执行:adb shell dumpsys window |findstr mCurre ...
- 51单片机学习笔记(郭天祥版)(9)——IIC、EEPROM
IIC是两根线,单总线,只有一根数据线,发送数据和读取收据都是一根线,像我们之前学的AD.DA都是许多线,许多线的话,这样做系统可以少浪费资源,少浪费控制IO口的资源,这种并行的处理速度快.所以线越多 ...
- JavaSE基础知识(5)—面向对象(Object类)
一.包 java.lang包,属于java中的核心包,系统默认导入的,不用手动导入该包中的类:Object.System.String.Integer等 1.包的好处 ①分类管理java文件,查找和管 ...
- 6. Redis复制
6. Redis复制6.1 配置6.1.1 建立复制6.1.2 断开复制6.1.3 安全性6.1.4 只读6.1.5 传输延迟6.2 拓扑6.3 原理6.3.1 复制过程6.3.2 数据同步6.3.3 ...
- 一个简单地template模板
之前的项目中用到了artTemplate模板,感觉挺有意思,于是查看相关资料,自己动手写了个简单地template模板插件.虽然会有一些不足,但也是自己的一番心血.主体代码如下 /* * 一个简单地t ...
- ng环境搭建步骤
1,安装node node -v查看版本号 2,安装淘宝镜像 npm config set registry https://registry.npm.taobao.org 3,安装cnpm npm ...
- Linux服务器上监控网络带宽的18个常用命令 zz
Linux服务器上监控网络带宽的18个常用命令 本文介绍了一些可以用来监控网络使用情况的Linux命令行工具.这些工具可以监控通过网络接口传输的数据,并测量目前哪些数据所传输的速度.入站流量和出站流量 ...