hdoj 5194 DZY Loves Balls【规律&&gcd】
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5194
题意:给你n个黑球,m个白球,每次从中随机抽取一个,如果抽到黑球记为1如果抽出来白球记为0,让你输出所有的可能性总数q和将这些组合中01出现的次数q,将q和p以q/p的形式输出最简形式
竟然就这样过了,只是看到了这个规律试试而已
#include<stdio.h>
#include<string.h>
#include<algorithm>
#define MAX 1010
using namespace std;
int gcd(int x,int y)
{
int c;
while(y)
{
c=y;
y=x%y;
x=c;
}
return x;
}
int main()
{
int n,m;
while(scanf("%d%d",&n,&m)!=EOF)
{
int x=n*m;
int y=n+m;
int ans=gcd(x,y);
printf("%d/%d\n",x/ans,y/ans);
}
return 0;
}
hdoj 5194 DZY Loves Balls【规律&&gcd】的更多相关文章
- HDU 5194 DZY Loves Balls
DZY Loves Balls Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) ...
- hdu5194 DZY Loves Balls 【概率论 or 搜索】
//yy:那天考完概率论,上网无聊搜个期望可加性就搜到这题,看到以后特别有亲和感,挺有意思的. hdu5194 DZY Loves Balls [概率论 or 搜索] 题意: 一个盒子里有n个黑球和m ...
- hdu 5645 DZY Loves Balls
DZY Loves Balls Accepts: 659 Submissions: 1393 Time Limit: 4000/2000 MS (Java/Others) Memory Lim ...
- HDU 5645 DZY Loves Balls 水题
DZY Loves Balls 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5645 Description DZY loves playing b ...
- BC#76.2DZY Loves Balls
DZY Loves Balls Accepts: 659 Submissions: 1393 Time Limit: 4000/2000 MS (Java/Others) Memory Lim ...
- 【BZOJ3309】DZY Loves Math 莫比乌斯反演+线性筛(好题)
[BZOJ3309]DZY Loves Math Description 对于正整数n,定义f(n)为n所含质因子的最大幂指数.例如f(1960)=f(2^3 * 5^1 * 7^2)=3, f(10 ...
- BZOJ 3309: DZY Loves Math
3309: DZY Loves Math Time Limit: 20 Sec Memory Limit: 512 MBSubmit: 761 Solved: 401[Submit][Status ...
- 【BZOJ】3309: DZY Loves Math 莫比乌斯反演优化
3309: DZY Loves Math Description 对于正整数n,定义f(n)为n所含质因子的最大幂指数.例如f(1960)=f(2^3 * 5^1 * 7^2)=3, f(10007) ...
- cf446C DZY Loves Fibonacci Numbers
C. DZY Loves Fibonacci Numbers time limit per test 4 seconds memory limit per test 256 megabytes inp ...
随机推荐
- poj 2976 Dropping tests 0/1分数规划
0/1分数规划问题,用二分解决!! 代码如下: #include<iostream> #include<stdio.h> #include<algorithm> # ...
- Java中List的排序
第一种方法,就是list中对象实现Comparable接口,代码如下: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 2 ...
- Win7 默认hosts文件
# Copyright (c) 1993-2009 Microsoft Corp. # # This is a sample HOSTS file used by Microsoft TCP/IP f ...
- SGU 101 修改
感谢这里. test4确实是个不连通的case,奇怪的是我用check函数跟if (check() == false)来判断这个case,当不连通时就死循环,得到的结果是不一样的,前者得到WA,后者得 ...
- POJ3080——Blue Jeans(暴力+字符串匹配)
Blue Jeans DescriptionThe Genographic Project is a research partnership between IBM and The National ...
- Python生成器与yield
列表推导与生成器表达式 当我们创建了一个列表的时候,就创建了一个可以迭代的对象: >>> squares=[n*n for n in range(3)] >>> f ...
- 查看Vim的option变量的值
以t_Co变量为例,最好用 :echo &t_Co 也可以使用 :set t_Co?,但是漏打?的话就会设置,得不偿失 要想知道在哪里这个变量被设置的,用 :verbose set t_Co? ...
- 给枚举加上Description,必要时,可以直接获取枚举类型代表的中文
http://www.cnblogs.com/lyl6796910/p/3958768.html
- poj 3278 Catch That Cow (bfs)
题目:http://poj.org/problem?id=3278 题意: 给定两个整数n和k 通过 n+1或n-1 或n*2 这3种操作,使得n==k 输出最少的操作次数 #include<s ...
- one-to-many many-to-one配置解释
one-to-many放在某个文件的配置中,表示这个文件是ONE的一方, 同样的many-to-one放在某个文件的配置中,表示这个文件是many的一方.