题目是这样的,每个人手中有a和b的钱数,c为a和b中间最小的一个。

每个回合,两个人胜利的概率都是0.5,胜利者从失败者手中获得c的钱数。

如果有一个人手中没钱的话,那么他就failer,游戏结束。

现在给你初始状态问你这次游戏需要进行的回合以及A胜利的期望值分别为多少?

这样的,自己手动模拟几组数据就会发现胜利的概率就是a/(a+b)。

对于回合数,我们可以深搜,但是有的可能有环,所以我们只要设置深搜上线只需要深度为20即可。因为超过20的肯定不会对小数前五位产生影响。

#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std; int a,b,n,m,k=;
double ans1,ans2; double dfs(int x,int y,int tep)
{
if (tep>) return ;
if (x== || y==) return ;
int cur=min(x,y);
return +0.5*(dfs(x-cur,y+cur,tep+)+dfs(x+cur,y-cur,tep+));
} int main()
{
scanf("%d",&n);
m=;
while (n--)
{
scanf("%d%d",&a,&b);
ans2=(double)a/(a+b);
ans1=dfs(a,b,);
printf("Case %d: %.6lf %.6lf\n",++m,ans1,ans2);
}
return ;
}

UVA12585_Poker End Games的更多相关文章

  1. Unity性能优化(3)-官方教程Optimizing garbage collection in Unity games翻译

    本文是Unity官方教程,性能优化系列的第三篇<Optimizing garbage collection in Unity games>的翻译. 相关文章: Unity性能优化(1)-官 ...

  2. Unity性能优化(4)-官方教程Optimizing graphics rendering in Unity games翻译

    本文是Unity官方教程,性能优化系列的第四篇<Optimizing graphics rendering in Unity games>的翻译. 相关文章: Unity性能优化(1)-官 ...

  3. Learning in Two-Player Matrix Games

    3.2 Nash Equilibria in Two-Player Matrix Games For a two-player matrix game, we can set up a matrix ...

  4. (转) Playing FPS games with deep reinforcement learning

    Playing FPS games with deep reinforcement learning 博文转自:https://blog.acolyer.org/2016/11/23/playing- ...

  5. Favorite Games

    Samurai II: Vengeance: http://www.madfingergames.com/games

  6. CF456D A Lot of Games (字典树+DP)

    D - A Lot of Games CF#260 Div2 D题 CF#260 Div1 B题 Codeforces Round #260 CF455B D. A Lot of Games time ...

  7. GDC2016 Epic Games【Bullet Train】 新风格的VR-FPS的制作方法

    追求“舒适”和“快感”的VR游戏设计方法   http://game.watch.impress.co.jp/docs/news/20160318_749016.html     [Bullet Tr ...

  8. Supercell only provide the best games for players

    Supercell only provide the best games for players Supercell start to change all, Supercell's first t ...

  9. 读书笔记2014第6本:《The Hunger Games》

    以前从未读过一本完整的英文小说,所有就在今年的读书目标中增加了一本英文小说,但在头四个月内一直没有下定决定读哪一本.一次偶然从SUN的QQ空间中看到Mockingjay,说是不错的英文小说,好像已经是 ...

随机推荐

  1. 2017 ACM-ICPC 亚洲区(西安赛区)网络赛

    A There is a tree with nn nodes, at which attach a binary 64*6464∗64 matrix M_i (1 \le i \le n)M ​i ...

  2. 基于 OpenCV 的人脸识别

    基于 OpenCV 的人脸识别 一点背景知识 OpenCV 是一个开源的计算机视觉和机器学习库.它包含成千上万优化过的算法,为各种计算机视觉应用提供了一个通用工具包.根据这个项目的关于页面,OpenC ...

  3. python与其他语言的区别

    C 和 Python.Java.C#等 C语言: 代码编译得到 机器码 ,机器码在处理器上直接执行,每一条指令控制CPU工作 其他语言: 代码编译得到 字节码 ,虚拟机执行字节码并转换成机器码再后在处 ...

  4. katalon系列九:DEBUG调试功能

    Katalon Studio做为一个IDE,具有和其他IDE一样的Debug功能,可以让我们方便的调试代码.将脚本切换到Script模式,在你想设断点的行首双击,或右击选择:(Groovy)Toggl ...

  5. 百度云 win10 125%界面模糊 解决

    右击图标 ->兼容性->更改高DPI设置 -> 替代高DPI缩放行为.打√

  6. TPO-17 C2 Reschedule part-time job in campus dining hall

    TPO-17 C2 Reschedule part-time job in campus dining hall 第 1 段 1.Listen to a conversation between a ...

  7. Cesium开发添加entity无法显示

    无代码报错,js查询entity数量发现确实添加进去了.但是在底图上就是不显示. 有可能是跨域产生的问题.打开开发者工具Console栏.查看是不是存在跨域错误. 解决跨域后entity正常加载.

  8. mariadb BINLOG_FORMAT = STATEMENT 异常

    当在mariadb中插入数据是报 InnoDB is limited to row-logging 异常: java.sql.SQLException: Cannot execute statemen ...

  9. 【转】SWFUpload使用指南

    原文出自:http://www.runoob.com/w3cnote/swfupload-guide.html SWFUpload是一个flash和js相结合而成的文件上传插件,其功能非常强大.以前在 ...

  10. 直接抱过来dd大牛的《背包九讲》来做笔记

    P01: 01背包问题 题目 有N件物品和一个容量为V的背包.第i件物品的费用是c[i],价值是w[i].求解将哪些物品装入背包可使这些物品的费用总和不超过背包容量,且价值总和最大. 基本思路 这是最 ...