HDU 5810 Balls and Boxes
n*(m-1)/(m*m)
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<iostream>
using namespace std;
typedef long long LL;
const double pi=acos(-1.0),eps=1e-;
void File()
{
freopen("D:\\in.txt","r",stdin);
freopen("D:\\out.txt","w",stdout);
}
inline int read()
{
char c = getchar(); while(!isdigit(c)) c = getchar(); int x = ;
while(isdigit(c)) { x = x * + c - ''; c = getchar(); }
return x;
} LL n,m;
LL gcd(LL a,LL b){ if(b==)return a; return gcd(b,a%b); } int main()
{
while(~scanf("%lld%lld",&n,&m))
{
if(n==&&m==) break;
LL x1=n*(m-),x2=m*m ;
LL GCD=gcd(x1,x2);
if(x1==) printf("0/1\n");
else printf("%lld/%lld\n",x1/GCD,x2/GCD);
}
return ;
}
HDU 5810 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 题目链接: 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 ...
- hdu 5810 Balls and Boxes 二项分布
Balls and Boxes Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)T ...
- HDU 5810 Balls and Boxes ——(数学,概率,方差)
官方题解看不太懂,参考了一些人的博客以后自己证明如下: 其中D(X)和E(X)的公式如下(参考自百度百科): 其中 p = 1 / m .(这是每一个单独事件发生的概率期望,在这里单独事件指的是一个球 ...
- hdu 5810:Balls and Boxes(期望)
题目链接 这题似乎就是纯概率论.. E(V)=D(X_i)=npq (p=1/m,p+q=1) #include<bits/stdc++.h> using namespace std; t ...
- 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 ...
- HDU5810 Balls and Boxes
Balls and Boxes Time Limi ...
- Codeforces 260C - Balls and Boxes
260C - Balls and Boxes 思路:模拟.在x前面找到最小值,如果没有,从0跳到n,继续找到最小值,边找最小值路过的点边减1.然后所有值都减去最小值,最小值那个点加上减去的值. 找到x ...
随机推荐
- js输入框对金额的匹配
/** * 金额格式化 * @param s * @param n * @returns {String} */ function fmoney(s, n) { n = n > 0 && ...
- Starting httpd: (98)Address already in use: make_sock: could not bind to address [::]:80
netstat -tulpn| grep :80 killall -9 httpd /etc/init.d/httpd start or service httpd start
- 自动化辅助工具Firebug和Firepath的安装
1.安装firefox浏览器,点击主菜单,选择“附加组件” 2.搜索Firebug和firepath点击安装 3.安装后点击浏览器的主菜单-web开发者-firebug即可打开 4.或者在页面右键选择 ...
- drupal 连表查询+分页
$query = db_select('Table','t'); $query->join('Table_A','a','on条件); $query->join('Table_B','b' ...
- react总结
在我的工作用到的最多就是backbone,其次还会有ember/Ext,backbone目前能实现我们team所需要实现的功能,因为我们的component不需要频繁的操作Dom,当后台API返回数据 ...
- linux 目录及文件的命名规则、ls操作
linux 命名: 1 不超过255个字符 2 严格区分大小写 3 除/外,其他的字符都是合法的 注意:1)避免文件名首字符使用+ - .(避免和隐藏文件混淆) 2)避免文件名使用空格,制表符以及@# ...
- VS编译wxWidgets
准备工作 下载wxWidgets源码包(官网),我用的是3.02版: 安装Visual Studio.我用的是VS 2015 RC: 编译源码 解压wxWidgets的源码包,会得到一大堆文件.进入b ...
- sublime text 设置
https://packagecontrol.io/installation#Simple 下载 php 自动补全 点击菜单栏的:Preferences: 选择:Setting-User项: 然后在大 ...
- Ubuntu操作相关笔记
Eclipse添加图标 #sudo vim /usr/share/applications/eclipse.desktop 写入以下内容 [Desktop Entry] Name=Eclipse Co ...
- 弹性布局EM的计算方法
文章来源: http://www.w3cplus.com/css/px-to-em 总结: 1.浏览器默认的字体大小为16PX,即1em 2.EM可以指定小数点的后三位 3.元素自身没有设置字体大小, ...