思路: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. hdu 1003 Max Sum (DP)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1003 Max Sum Time Limit: 2000/1000 MS (Java/Others)   ...

  2. kimbits_USACO

    StringsobitsKim Schrijvers Consider an ordered set S of strings of N (1 <= N <= 31) bits. Bits ...

  3. java===java基础学习(3)---数据类型转换,运算符级别,枚举类型

    数据类型转换: 有的时候,程序需要将数据类型,比如 int + float ,结果是float, 这里的int就被转换为float类型,属于合法转换. Java中的合法转换如下图: 红色表示无信息丢失 ...

  4. 【Educational Codeforces Round 19】

    这场edu蛮简单的…… 连道数据结构题都没有…… A.随便质因数分解凑一下即可. #include<bits/stdc++.h> #define N 100005 using namesp ...

  5. English——Unit 2

    radiant radiate radical ideal ideology identical identification identify identity journal jounalist ...

  6. linux下查看机器配置

    查看cpu信息:lscpu Architecture: x86_64 CPU op-mode(s): 32-bit, 64-bit Byte Order: Little Endian CPU(s): ...

  7. python和语法糖

       语法糖(syntactic sugar)是指编程语言中可以更容易的表达一个操作的语法,它可以使程序员更加容易去使用这门语言:操作可以变得更加清晰.方便,或者更加符合程序员的编程习惯.(百度百科的 ...

  8. hdu 3367(与最大生成树无关。无关。无关。重要的事情说三遍+kruskal变形)

    Pseudoforest Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Tot ...

  9. WP集成七牛云存储(原创)

    借助:七牛镜像存储 WordPress 插件 https://wordpress.org/plugins/wpjam-qiniu/ 安装本插件1.4.5及以上版本,请先安装并激活WPJAM BASIC ...

  10. lr_Vugen界面图