【Uva10288】——Coupons概率
来源:互联网 发布:nginx启用gzip压缩 编辑:程序博客网 时间:2024/06/11 08:49
题意:一共有n种不同的Coupons,每次得到每种Coupons的概率是相同的,问期望多少次得到所有的n种Coupons
假设我们已经得到k种Coupons,那么我们得到新的Coupons的概率为
#include <bits/stdc++.h>using namespace std;typedef long long LL;int GetLen(LL s) { int ans = 0; while(s) { ans++; s/=10; } return ans;}int main() { int n; while(~scanf("%d",&n)) { LL p =0, q =1; for(int i = 1; i<=n; i++) { LL a = p*i+q; LL b = q*i; p = a, q = b; LL g = __gcd(p,q); p/=g,q/=g; } p*=n; LL g = __gcd(p,q); p/=g,q/=g; if(p%q ==0) { printf("%lld\n",p/q); } else { LL a = p/q; LL b = p%q; int len = GetLen(q); if(a == 0) { printf("%lld\n",b); for(int i = 1; i<=len; i++) printf("-"); printf("\n"); printf("%lld\n",q); } else { int len1 = GetLen(a)+1; for(int i = 1; i<=len1; i++) printf(" "); printf("%lld\n",b); printf("%lld ",a); for(int i = 1; i<=len; i++) printf("-"); printf("\n"); for(int i = 1; i<=len1; i++) printf(" "); printf("%lld\n",q); } } } return 0;}
1 0
- 【Uva10288】——Coupons概率
- UVA10288 - Coupons (概率+递推)
- UVA10288 Coupons
- UVA10288 Coupons
- uva10288 Coupons
- [UVA10288] Coupons && 数学期望
- 【ACM刷题录】UVa10288 Coupons
- UVA10288 Coupons(卡输出神题)
- Uva10288(概率期望+暴力模拟)
- uva 10288 - Coupons(概率)
- UVa10288
- UVa10288
- UVa10288
- Coupons - UVa 10288 概率dp
- 【UVA】10288-Coupons(概率)
- UVA 10288 - Coupons(概率递推)
- UVA - 10288 Coupons (概率+递推)
- Uva 10288 Coupons (概率dp)
- C++标准模板库
- python自学之路-03
- 制作顶部导航平滑收起和展开
- yum 安装出错 Couldn't resolve host 'mirrors.163.com'"Trying other mirror.
- MySQL外网连接不上
- 【Uva10288】——Coupons概率
- masterJ2SE篇007——Serializable serialVersionUID
- 回形数组的输出
- Laravel--项目报错fileinfo is missing
- 2 linux下安装服务端
- J-Link修复(win7 64位)
- POI 导出Excel 并且根据内容设置列宽自适应
- Python基础2注释+变量+字符串
- JMeter BeanShell 的使用-请求加密-返回自动解密处理