uva 11673 Garbage Remembering Exam (概率)
题目链接: http://vjudge.net/problem/viewProblem.action?id=42000
该过程为随即过程,因此总期望值等于个单词对应的期望值,即它们wasted的概率
#include <stdio.h>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <cmath> using namespace std;
#define lson o<<1
#define rson o<<1|1
#define max(a,b) (a)>(b)?(a):(b)
#define min(a,b) (a)<(b)?(a):(b)
#define INF 200000000
#define N 100010
typedef long long ll;
long double lg[N]; void init (){
lg[]=;
for(int i=;i<N;i++){
lg[i]=(long double)log(i)+lg[i-];
}
}
int main(){
int n,k,cs=;
init();
while(scanf("%d%d",&n,&k) && n){
long double p,ans=;
int up,down,put=*k;
if(*k>n-)put=n-;
long double l0=lg[n-]-lg[n--put];
for(int i=;i<=n;i++){
up=max(i--k,);
down=max(n-i-k,);
if(up+down>=put)p=exp(lg[up+down]-lg[up+down-put]-l0);
else p=;
ans+=-p;
}
printf("Case %d: %.4lf\n",cs++,(double)ans);
}
return ;
}
uva 11673 Garbage Remembering Exam (概率)的更多相关文章
- UVA - 11637 Garbage Remembering Exam (组合+可能性)
Little Tim is now a graduate,and is thinking about higher studies. However, he first needs to appear ...
- UVA 11637 Garbage Remembering Exam
#include <iostream> #include <stdio.h> #include <cstring> #include <math.h> ...
- 🔺 Garbage Remembering Exam UVA - 11637()
题目大意:给你N个单词,有两种方法随机排列,一种随机排成一行,另一种随机排成一圈,当两个单词之间的距离在两种排列中都严格小于K时,则这两个单词构成无效单词,问无效单词的期望. 解题思路:首先对于一排单 ...
- uva 10755 - Garbage Heap
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&p ...
- UVa 10491 Cows and Cars (概率&广义三门问题 )
10491 - Cows and Cars Time limit: 3.000 seconds http://uva.onlinejudge.org/index.php?option=com_onli ...
- [uva 11762]Race to 1[概率DP]
引用自:http://hi.baidu.com/aekdycoin/item/be20a91bb6cc3213e3f986d3,有改动 题意: 已知D, 每次从[1,D] 内的所有素数中选择一个Ni, ...
- UVA 10828 - Back to Kernighan-Ritchie(概率+高斯消元)
UVA 10828 - Back to Kernighan-Ritchie 题目链接 题意:给图一个流程图,有结点的流程,每次进入下一个流程概率是均等的,有q次询问,求出每次询问结点的运行期望 思路: ...
- uva 11722 - Joining with Friend(概率)
题目连接:uva 11722 - Joining with Friend 题目大意:你和朋友乘火车,而且都会路过A市.给定两人可能到达A市的时段,火车会停w.问说两人能够见面的概率. 解题思路:y = ...
- UVA 11427 - Expect the Expected(概率递归预期)
UVA 11427 - Expect the Expected 题目链接 题意:玩一个游戏.赢的概率p,一个晚上能玩n盘,假设n盘都没赢到总赢的盘数比例大于等于p.以后都不再玩了,假设有到p就结束 思 ...
随机推荐
- html 商品展示框
<!doctype html> <html> <head> <meta charset="utf-8"> <title> ...
- 【HDOJ】2717 Catch That Cow
bfs. /* 2717 */ #include <iostream> #include <cstdio> #include <cstring> #include ...
- winform登录时,在密码框按下回车,直接登陆
//按回车,焦点跳到密码文本框 private void txtUserName_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyCha ...
- UVA-10735 - Euler Circuit(混合欧拉回路输出)
题意:给你一个图,有N个点,M条边,这M条边有的是单向的,有的是双向的. 问你能否找出一条欧拉回路,使得每条边都只经过一次! 分析: 下面转自别人的题解: 把该图的无向边随便定向,然后计算每个点的入度 ...
- Qt入门(16)——组装窗口部件
这个例子显示了创建几个窗口部件并用信号和槽把它们连接起来,和如何处理重新定义大小事件. #include <qapplication.h> #include <qpushbutton ...
- (转载)mysql查询一天,查询一周,查询一个月的数据
(转载)http://www.cnblogs.com/likwo/archive/2010/04/16/1713282.html 查询一天: select * from table where to_ ...
- HDOJ(HDU) 2162 Add ‘em(求和)
Problem Description Write a program to determine the summation of several sets of integers. Input Th ...
- [jAudio] JAVA上经典特征提取工具
1.下载Jar包后引入 现在的问题是jAudio通常是给人UI进行操作的,直接使用怎么办? 看了源码,发现特征提取是通过类之间交叉调用实现的,是否有办法整合一下?
- DNA repair - HDU 2457(自动机+dp)
题目大意:给你N个DNA的串,也就是至包含'A','T','G','C'四种碱基的,这些给定的串都是带有遗传病的,然后给你一个不会超过1000的串,问你至少几个地方才能让这个串不包含遗传病,如果不论怎 ...
- @property 的本质是什么?ivar、getter、setter 是如何生成并添加到这个类中的
出题者简介: 孙源(sunnyxx),目前就职于百度 整理者简介:陈奕龙(子循),目前就职于滴滴出行. 转载者:豆电雨(starain)微信:doudianyu @property 的本质是什么? @ ...