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 ...
随机推荐
- Angular2.0 基础: Form
对于Angular2.0 的Form表单中的隐藏和验证,个人觉得还是挺有意思的. 1.通过ngModel 跟踪修改状态与验证. 在表单中使用 ngModel 可以获得更多的控制权,包括一些常用的验证. ...
- 2017-2018-1 20179205《Linux内核原理与设计》第六周作业
<Linux内核原理与设计> 视频学习及操作 给MenuOS增加time和time-asm命令的方法: 1.更新menu代码到最新版 rm menu -rf //强制删除menu, rm ...
- Python模块学习 - Fileinput
Fileinput模块 fileinput是python提供的标准库,使用fileinput模块可以依次读取命令行参数中给出的多个文件.也就是说,它可以遍历 sys.argv[1:],并按行读取列表中 ...
- linux 自旋锁和信号量【转】
转自:http://blog.csdn.net/xu_guo/article/details/6072823 版权声明:本文为博主原创文章,未经博主允许不得转载. 自旋锁最多只能被一个可执行线程持有( ...
- 【bzoj1026】windy数
江泽OJ好,远离bzoj保平安. 仍然沿用之前的记忆化搜索的办法即可. #include<bits/stdc++.h> #define N 10010 using namespace st ...
- python中eval函数使用
把字符串转换为字典: s = "{'a':1}" eval(s)
- swiper 滑动插件,小屏单个显示滑动,大屏全部显示
var currSwiperIndex=0; function widthHandle(){ var level = widthLevel(); if(level==1){ //单个显示,滑动 if( ...
- java中的三元运算符
格式: 关系表达式 ? 表达式1:表达式2 public class OperatorDemo { public static void main(String[] args){ int a = 10 ...
- Foreach与迭代器
Foreach与迭代器 Foreach语句可以用于数组和集合的遍历.之所以能够工作,是因为Java SE5引入了新的被称为Iterable的接口,该接口中包含一个能够产生Iterator的iterat ...
- 微信小程序实战篇-下拉刷新与加载更多
下拉刷新 实现下拉刷新目前能想到的有两种方式 1. 调用系统的API,系统有提供下拉刷新的API接口 2. 监听scroll-view,自定义下拉刷新,还记得scroll-view里面有一个binds ...