思路:p[n][m][0]表示A为n,B为m,A为先手胜的概率;

         p[n][m][1]表示A为n,B为m,B为先手胜的概率。

         d[i]表示圆盘上数字的大小。

容易得到表达式为:

      

代码如下:

 

 #include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<vector>
#define M 502
using namespace std;
double p[M][M][];
int d[]={,,,,,,,,,,,,,,,,,,,,,};
int cal(int a,int b){ return a>=b?a-b:a;}
int main()
{
int n,m;
for(n=;n<M;n++){
p[][n][]=;
p[n][][]=;
}
for(n=;n<M;n++)
for(m=;m<M;m++){
if(n<=) p[n][m][]=n/20.0;
if(m<=) p[n][m][]=m/3.0;
for(int k=;k<;k++){
double a=;
for(int i=;i<=;i++)
a+=p[cal(n,d[i])][m][];
p[n][m][]=-a/20.0;
double b=1e300;
for(int i=;i<=;i++){
double c=;
for(int j=-;j<=;j++)
c+=p[n][cal(m,d[i+j])][];
c/=3.0;
if(b>c) b=c;
}
p[n][m][]=-b;
if(n>) break;
}
}
while(scanf("%d",&n)&&n){
printf("%.12lf %.12lf\n",p[n][n][],p[n][n][]);
}
return ;
}

 

 

 

 

hdu 4074 Darts的更多相关文章

  1. HDU - 4074 - Sum

    先上题目: Sum Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total ...

  2. HDU 5643 King's Game 打表

    King's Game 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5643 Description In order to remember hi ...

  3. HDOJ 2111. Saving HDU 贪心 结构体排序

    Saving HDU Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total ...

  4. 【HDU 3037】Saving Beans Lucas定理模板

    http://acm.hdu.edu.cn/showproblem.php?pid=3037 Lucas定理模板. 现在才写,noip滚粗前兆QAQ #include<cstdio> #i ...

  5. hdu 4859 海岸线 Bestcoder Round 1

    http://acm.hdu.edu.cn/showproblem.php?pid=4859 题目大意: 在一个矩形周围都是海,这个矩形中有陆地,深海和浅海.浅海是可以填成陆地的. 求最多有多少条方格 ...

  6. HDU 4569 Special equations(取模)

    Special equations Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u S ...

  7. HDU 4006The kth great number(K大数 +小顶堆)

    The kth great number Time Limit:1000MS     Memory Limit:65768KB     64bit IO Format:%I64d & %I64 ...

  8. HDU 1796How many integers can you find(容斥原理)

    How many integers can you find Time Limit:5000MS     Memory Limit:32768KB     64bit IO Format:%I64d ...

  9. hdu 4481 Time travel(高斯求期望)(转)

    (转)http://blog.csdn.net/u013081425/article/details/39240021 http://acm.hdu.edu.cn/showproblem.php?pi ...

随机推荐

  1. Exploring Qualcomm's TrustZone Implementation

    转自  http://bits-please.blogspot.com/2015/08   (需要FQ, 狗日的墙) In this blog post, we'll be exploring Qua ...

  2. device tree --- #interrupt-cells property

    device tree source Example1 interrupt-controller@e000e100 { ... ... #interrupt-cells = <0x1>; ...

  3. Redis 3.0 编译安装

    Redis 3.0 编译安装 http://www.xuchanggang.cn/archives/991.html

  4. [New learn]@class和#import的区别使用

    1.简介 我们在查看代码的时候经常会发现有些地方使用@class而有些地方使用#import,他们到底有什么区别呢, 本文意图去归纳和总结这两种类引用的是的处理方法和规则. 2.分析 此小节会通过一些 ...

  5. Tomcat+Apache 负载均衡

    1.JDK1.8和Tomcat7.0不兼容,支持Tomcat8.0. 集群架构图: 2.负载均衡:负载的基础是集群,集群就是一组连在一起的计算机,从外部看它是一个系统,各节点可以是不同的操作系统或不同 ...

  6. Redis -- 过期时间 和 缓存 例子

    1.设置 key的生存时间,过期自动删除 exprire key  seconds    设置过期时间 秒数 ttl key   查询剩余时间 如果 设置了过期时间.对key进行 set 操作,会清除 ...

  7. Leetcode 之Anagrams(35)

    回文构词法,将字母顺序打乱.可将字母重新排序,若它们相等,则属于同一组anagrams. 可通过hashmap来做,将排序后的字母作为key.注意后面取hashmap值时的做法. vector< ...

  8. Myeclipse实用快捷键总结

    alt+shift+J 为选中的类/方法添加注释 ctrl+T 显示选中类的继承树 ctrl+shift+X/Y 将选中的字符转换为大写/小写 ctrl+shift+R 打开资源 ctrl+shift ...

  9. 一、安装ansible

    yum -y install epel-release  \\安装epel源 yum -y install ansible1.9.noarch   \\安装ansible自动化 ansible目录简要 ...

  10. [转]6个HelloWorld

    原文地址:点击打开链接 转这个帖子,是因为看了这个帖子使我明白了一个道理:一旦你发散自己的思维,激发自己的创意,就会发现原来编程是这么的好玩. 原文标题为<6个变态的C语言Hello World ...