hdu 4074 Darts
思路: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的更多相关文章
- HDU - 4074 - Sum
先上题目: Sum Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total ...
- HDU 5643 King's Game 打表
King's Game 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5643 Description In order to remember hi ...
- HDOJ 2111. Saving HDU 贪心 结构体排序
Saving HDU Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total ...
- 【HDU 3037】Saving Beans Lucas定理模板
http://acm.hdu.edu.cn/showproblem.php?pid=3037 Lucas定理模板. 现在才写,noip滚粗前兆QAQ #include<cstdio> #i ...
- hdu 4859 海岸线 Bestcoder Round 1
http://acm.hdu.edu.cn/showproblem.php?pid=4859 题目大意: 在一个矩形周围都是海,这个矩形中有陆地,深海和浅海.浅海是可以填成陆地的. 求最多有多少条方格 ...
- HDU 4569 Special equations(取模)
Special equations Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u S ...
- HDU 4006The kth great number(K大数 +小顶堆)
The kth great number Time Limit:1000MS Memory Limit:65768KB 64bit IO Format:%I64d & %I64 ...
- HDU 1796How many integers can you find(容斥原理)
How many integers can you find Time Limit:5000MS Memory Limit:32768KB 64bit IO Format:%I64d ...
- hdu 4481 Time travel(高斯求期望)(转)
(转)http://blog.csdn.net/u013081425/article/details/39240021 http://acm.hdu.edu.cn/showproblem.php?pi ...
随机推荐
- Select 使用不当引发的core,你应该知道的
排查一个死机问题,搞了好几天时间,最终确定原因:最终确定问题原因,在此分享一下: 第一步:常规根据core文件查看栈信息,gdb –c core xxxx 如下rip不正确,指令地址错乱,栈信息已破坏 ...
- idea 调试远程tomcat
# ----- Execute The Requested Command ----------------------------------------- JAVA_OPTS="-age ...
- inetdev_init && inetdev_destroy
inetdev_init为传入设备分配和绑定ip控制块,查看其调用关系如下: fs_initcall(inet_init)---->inet_init---->ip_init----> ...
- Linux 入门记录:十三、Linux 扩展权限
一.默认权限 每一个终端都有一个 umask 属性,是用来确定新建文件或目录的默认权限的“掩码”(mask 有“掩码”的含义,至于 u,后面说). Linux 中一般有默认的权限掩码,使用命令 uma ...
- python基础===trheading 模块
'''threading模块''' import threading import time def music(func): for i in range(2): print("[+]i ...
- 《LINUX3.0内核源代码分析》第二章:中断和异常 【转】
转自:http://blog.chinaunix.net/uid-25845340-id-2982887.html 摘要:第二章主要讲述linux如何处理ARM cortex A9多核处理器的中断.异 ...
- 己动手创建最精简的Linux
己动手创建最精简的Linux http://blog.sina.com.cn/s/blog_71c87c170101e7ru.html 首次 LFS 搭建全过程 http://zmyxn.blog.5 ...
- go语言爬虫goquery和grequests的使用
/*下载工具*/ package main import ( "fmt" //go语言版本的jquery "github.com/PuerkitoBio/goquery& ...
- linux运维记
nmap 127.0.0.1 命令查看当前服务器对外有多少端口,用于检查漏洞 vim ctrl+z ,jobs,fg 切换控制应用程序 vim 执行命令 #!sh aa.sh执行命令 运维系统监控开源 ...
- [How to]如何自定义plist文件和读取plist文件内容
1.简介 plist作为IOS的固化文件,就好比java中properties文件,但是在IOS中plist是可读写的. 本文将介绍自定义静态的plist文件. 2.自定义静态plist文件 右击你的 ...