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 ...
随机推荐
- Tomcat 配置MySQL连接池
<!--配置mysql数据库的连接池, 需要做的额外步骤是将mysql的Java驱动类放到tomcat的lib目录下 maxIdle 连接池中最多可 ...
- Trie树详解(转)
特别声明 本文只是一篇笔记类的文章,所以不存在什么抄袭之类的. 以下为我研究时参考过的链接(有很多,这里我只列出我记得的): Trie(字典树)的应用——查找联系人 trie树 Trie树:应用于统计 ...
- FineCMS v5.4.1 后台getshell
0x01.前言 最近在学代码审计,拿finecms学习的时候偶然发现的,应该算个1day吧 0x02.正文 FineCMS v5.4.1 后台域名配置处 域名配置文件config/domain.php ...
- k8s环境清理
每一种方法 #!/bin/shdocker rm -f $(docker ps -qa)docker volume rm $(docker volume ls -q)cleanupdirs=" ...
- Android 菊花加载工具类
先看看实现效果图 1.首先自定义一个类继承系统ProgressDialog /** * Created by hanbao0928 on 2018/11/1. */ public class Dial ...
- CentOS 7 lnmp环境配置laravel项目的问题总结!
一.最常见的几个问题 1.部署好站点后,访问站点的时候始终是“File Not Found”!(nginx中的路由配置问题) 2.除了根目录可以访问其它的访问全是403问题!(权限问题) 3.除了根目 ...
- grid布局
display: grid; //行 //每一行中有几块,每块所占的width的百分比(1) grid-template-columns: 70% 30%; //每个div的width 100px,自 ...
- Eclipse oxygen 版本汉化教程
Eclipse oxygen 版本汉化步骤如下: 第一步:打开Eclipse 第二步:浏览器打开网址 http://www.eclipse.org/babel/downloads.php 1.复制对应 ...
- python requests库爬取网页小实例:ip地址查询
ip地址查询的全代码: 智力使用ip183网站进行ip地址归属地的查询,我们在查询的过程是通过构造url进行查询的,将要查询的ip地址以参数的形式添加在ip183url后面即可. #ip地址查询的全代 ...
- Linux 学习笔记 2:文件系统
1.文件系统层次结构 系统目录内容: /: 根目录(之后的/都是目录分隔符) /home:用户目录 /bin: Unix常用命令,如bash, date, cat, tar等 /sbin: 管理员命令 ...