HDU 5194 DZY Loves Balls
DZY Loves Balls
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 807 Accepted Submission(s): 439
balls and m white
balls in the big box.
Now, DZY starts to randomly pick out the balls one by one. It forms a sequence S.
If at the i-th
operation, DZY takes out the black ball, Si=1,
otherwise Si=0.
DZY wants to know the expected times that '01' occurs in S.
The first line contains two integers, n, m(1≤n,m≤12)
coprime)
1 1
2 3
1/2
6/5HintCase 1: S='01' or S='10', so the expected times = 1/2 = 1/2
Case 2: S='00011' or S='00101' or S='00110' or S='01001' or S='01010'
or S='01100' or S='10001' or S='10010' or S='10100' or S='11000',
so the expected times = (1+2+1+2+2+1+1+1+1+0)/10 = 12/10 = 6/5
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<string>
#include<string.h>
#include<math.h>
#include<map>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;
#define MAX 0x3f3f3f3f
#define MIN -0x3f3f3f3f
#define PI 3.14159265358979323
#define N 1005
int gcd(int n, int m)
{
int temp;
if (m > n)
swap(m, n);
if (m == 1 || n == 1)
return 1;
temp = n%m;
while (temp != 0)
{
n = m;
m = temp;
temp = n%m;
}
return m;
}
int main()
{
int n, m;
int num;
int nn, mm;
while (scanf("%d%d", &n, &m) != EOF)
{
nn = m*n;
mm = m + n;
num = gcd(nn, mm);
printf("%d/%d\n", nn / num, mm / num);
}
return 0;
}
HDU 5194 DZY Loves Balls的更多相关文章
- HDU 5645 DZY Loves Balls 水题
DZY Loves Balls 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5645 Description DZY loves playing b ...
- hdu 5645 DZY Loves Balls
DZY Loves Balls Accepts: 659 Submissions: 1393 Time Limit: 4000/2000 MS (Java/Others) Memory Lim ...
- hdoj 5194 DZY Loves Balls【规律&&gcd】
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5194 题意:给你n个黑球,m个白球,每次从中随机抽取一个,如果抽到黑球记为1如果抽出来白球记为0,让你 ...
- hdu5194 DZY Loves Balls 【概率论 or 搜索】
//yy:那天考完概率论,上网无聊搜个期望可加性就搜到这题,看到以后特别有亲和感,挺有意思的. hdu5194 DZY Loves Balls [概率论 or 搜索] 题意: 一个盒子里有n个黑球和m ...
- HDU 5646 DZY Loves Partition
题目链接: hdu:http://acm.hdu.edu.cn/showproblem.php?pid=5646 bc:http://bestcoder.hdu.edu.cn/contests/con ...
- HDU 5646 DZY Loves Partition 数学 二分
DZY Loves Partition 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5646 Description DZY loves parti ...
- hdu 5195 DZY Loves Topological Sorting 线段树+拓扑排序
DZY Loves Topological Sorting Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/sho ...
- hdu 5195 DZY Loves Topological Sorting BestCoder Round #35 1002 [ 拓扑排序 + 优先队列 || 线段树 ]
传送门 DZY Loves Topological Sorting Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 131072/131 ...
- hdu.5195.DZY Loves Topological Sorting(topo排序 && 贪心)
DZY Loves Topological Sorting Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 131072/131072 ...
随机推荐
- 顺序线性表 ---- ArrayList 源码解析及实现原理分析
原创播客,如需转载请注明出处.原文地址:http://www.cnblogs.com/crawl/p/7738888.html ------------------------------------ ...
- sql的基本知识
一.什么是sql? 全称:"结构化查询语言(Structured Query Language)",是1974年由Boyce和Chamberlin提出来的,现已经成为关系数据库的 ...
- js 判断当前是什么浏览器
function getExplorer() { var explorer = window.navigator.userAgent; //ie if (explorer.indexOf(" ...
- eclipse中project facet问题
一般出现在从别处import的项目上,只有项目文件夹上有红叉,其他地方都正常,现总结个人的几个解决方案: 有几种可能: 1,编码设置是否一致,也即是你项目原来的编码和现在eclipse用的默认编码是否 ...
- web消息推送-goesay
原文:http://www.upwqy.com/details/22.html 1 GoEasy简介: GoEasy - Web实时消息推送服务专家 最简单的方式将消息从服务器端推送至客户端 最简单的 ...
- linux GCC 编译多个.c/.h文件
基本认识: #include <xxx>:首先去系统目录中找头文件,如果没有在到当前目录下找.像标准的头文件 stdio.h.stdlib.h等用这个方法. #include " ...
- Hadoop 中 最重要的两个模块
Hadoop 中 最重要的两个模块 HDFS 分布式的文件系统 主节点: NameNode SecondaryNamenode ResourceManager 从节点: DataNode Node ...
- AngularJS学习篇(二十)
AngularJS 包含 在 AngularJS 中,你可以在 HTML 中包含 HTML 文件. 使用 AngularJS, 你可以使用 ng-include 指令来包含 HTML 内容: < ...
- ldap数据库--ODSEE--复制协议
简单介绍一下ODSEE的复制拓扑的建立,复制协议可以通过管理界面进行创建,也可以通过命令行创建.在此之前需要了解一些复制协议的相关概念,这里针对OESEE. 1,复制角色 master(提供者,也可以 ...
- Deploy .Net project automatically with MsBuild and MsDeploy (1)
Q: How to change parameter values in configuration files dynamically In the first section http://www ...