【uva11421】玩纸牌
数学期望。
#include<bits/stdc++.h>
const int N=;
using namespace std;
double d[N][N],p;
int main(){
int T,n,a,b,cnt=;double p;scanf("%d",&T);
while(T--){
memset(d,,sizeof(d));
scanf("%d/%d%d",&a,&b,&n);
p=(double)a/b;
d[][]=;d[][]=;
for(int i=;i<=n;i++)
for(int j=;j*b<=a*i;j++){
if(!j) d[i][j]=d[i-][j]*(-p);
else d[i][j]=d[i-][j]*(-p)+d[i-][j-]*p;
}
double q=;
for(int i=;i<=n;i++)q+=d[n][i];
printf("Case #%d: %d\n",++cnt,int(/q));
}
}
【uva11421】玩纸牌的更多相关文章
- UVA11427玩纸牌(全概率+递推)
题意: 一个人玩纸牌游戏,他每天最多玩n局,枚举获胜的概率是a/b,每天玩牌只要获胜概率达到p,那么他今天就不玩了,明天接着玩,如果有一天他的概率没有达到p,(没有达到p的话他今天一定是玩 ...
- 【UVA】【11427】玩纸牌
数学期望 也是刘汝佳老师白书上的例题……感觉思路很神奇啊 //UVA 11427 #include<cmath> #include<cstdio> #include<cs ...
- COGS 1489玩纸牌
%%%http://blog.csdn.net/clover_hxy/article/details/53171234 #include<bits/stdc++.h> #define LL ...
- CSS命名规范——BEM思想(非常赞的规范)
人们问我最多的问题之一是在CSS类名中“--”和“__”是什么意思?它们的出现是源于BEM和Nicolas Gallagher... BEM的意思就是块(block).元素(element).修饰符( ...
- javascript作用域(Scope),简述上下文(context)和作用域的定义
网页制作Webjx文章简介:这篇文章将正面解决这个问题:简述上下文(context)和作用域的定义,分析可以让我们掌控上下文的两种方法,最后深入一种高效的方案,它能有效解决我所碰到的90%的问题. 作 ...
- 越狱Season 1- Episode 18: Bluff
Season 1, Episode 18: Bluff -Michael: Scofield Scofield Michael Scofield Michael Scofield -Patoshik: ...
- UVA 11427 Expect the Expected (期望)
题目链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=26&pa ...
- windows XP系统内核文件分析(全)
Windows XP个别 System32 文件 System32 文件夹下个别要移除的文件 我们就要删除另外600 个 system32 文件...我们要一次把它们全都解决掉. 以下是我所删除的 S ...
- Python解决codeforces ---- 1
第一题 1A A. Theatre Square time limit per test 2 seconds memory limit per test 64 megabytes input stan ...
随机推荐
- (转)基于CUDA的GPU光线追踪
作者:Asixa 链接:https://zhuanlan.zhihu.com/p/55855479 来源:知乎 著作权归作者所有.商业转载请联系作者获得授权,非商业转载请注明出处. 替STL. ...
- c free 使用MSDN library定制
为了不使用vc6但是还要使用visual assist的各种自动功能,决定使用c free ,但是怎么调用微软的MSDN library呢,我目前使用的版本是MSDN 1.5精简版bing自动翻译的. ...
- 问题 A: 完数
问题 A: 完数 时间限制: 1 Sec 内存限制: 32 MB提交: 252 解决: 178[提交][状态][讨论版][命题人:外部导入] 题目描述 求1-n内的完数,所谓的完数是这样的数,它的 ...
- LeetCode - 35. Search Insert Position(48ms)
Given a sorted array and a target value, return the index if the target is found. If not, return the ...
- python基础训练营02
任务二 时长:2天 1. 列表 a. 标志 b. 基本操作(创建,append( ),pop( ) ,del( ), 拷贝) c. 列表相关方法 2. 元组 a. 标志 b. 基本操作(创建及不可变性 ...
- 官方文档 恢复备份指南七 Using Flashback Database and Restore Points
本章内容: Understanding Flashback Database, Restore Points and Guaranteed Restore Points Logging for Fla ...
- 【EasyNetQ】- 控制队列名称
在为队列生成名称时,EasyNetQ的默认行为是使用消息类型名称并将其附加到订阅ID.例如PartyInvitation,命名空间中的消息类型EasyNetQ.Tests.Integration将使用 ...
- Linux 项目实用命令
总结一下Linux下常用的命令 nc nc命令,这是Linux一般都带有的,被誉为“瑞士军刀”.windows和Linux都有,可以下载安装对应的平台工具.使用UDP和TCP协议的网络连接去读写数据, ...
- hdu 2199 Can you solve this equation? (二分法)
Can you solve this equation? Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K ( ...
- [Leetcode] Best time to buy and sell stock ii 买卖股票的最佳时机
Say you have an array for which the i th element is the price of a given stock on day i. Design an a ...