poj3876 darts
| Time Limit: 1000MS | Memory Limit: 65536K | |||
| Total Submissions: 58 | Accepted: 32 | Special Judge | ||
Description
They always play 501, one of the easiest games. Players start with a score of N points (typically, N = 501, hence the name) and take turns throwing darts. The score of each player decreases by the value of the section hit by the dart, unless the score becomes negative, in which case it remains unchanged. The first player to reach a score of 0 wins. The figure below shows the dartboard with which the game is played.

As the clock ticks closer to midnight and they start running out of beer, everyone wonders the same: is it worth trying to aim the dart at a specic section? Or is it better just to throw the dart at a random section on the dartboard? You are asked to deal with the question by finding out what would happen if two players (A and B) applying these two different strategies were to play against each other:
Player A throws the darts at random, and consequently they land with equal probability in each of the sections of the dartboard.
If Player B aims at a certain section, the dart has the same probability of landing in the correct one as in each of the two adjacent ones (the neighbouring regions to the left and right). Moreover, he is completely aware of his ability and sober enough to aim at the section that maximizes his probability of winning.
Given the initial score of both players, can you determine the probability that the first player wins? Of course, being the first to throw a dart might be advantageous, so the answer depends on who plays first.
Input
Output
Sample Input
5
100
0
Sample Output
0.136363636364 0.909090909091
0.072504908290 0.950215081962 题目大意:A,B两人比赛射飞镖,每个人都有一个一样的初始分数n,两人轮流扔。投中a时,如果n大于等于a,n=n-a,否则n不变。n先为0的一方胜。
两人的策略不同,A随机射,每个数字射中的概率为20分之一。B瞄准某个数字射,但射中的概率只有三分之一,还有另外三分之一射中左右两个。
给出N,求A先射A赢的概率以及B先射B赢的概率。
思路:很容易想出来是概率dp,特殊情况也比较比较好处理。但问题是这里的状态会出现从自身到自身的状态,即dp[i][j]的某一部分是由dp[i][j]推倒而来的,这就形成了一个环。这里有两种解决方法,一是将可能出现环的状态反复迭代做,做上几十次,这样将逐步逼近正确值。比较好写,但运行时间较长。二是把所有环列出,这样将会有许多个等式,然后用高斯消元直接求,速度比较快,但比较难写。
本人采用的是第一种方法,但在poj上不是tle就是wa,实在找不出一个合适的迭代次数,无奈打表。下面给出打表程序。
/*
* Author: Joshua
* Created Time: 2014年08月23日 星期六 22时20分08秒
* File Name: poj3876.cpp
*/
#include<cstdio>
#define maxn 505
int a[]={,,,,,,,,,,,,,,,,,,,,,};
double dp1[maxn][maxn],dp2[maxn][maxn];
void solve()
{
for (int i=;i<maxn;++i)
{
dp1[][i]=;
dp2[i][]=;
}
for (int i=;i<=;++i)
for (int j=;j<=;++j)
{
for (int t=;t<=;++t)
{
dp1[i][j]=;
for (int k=;k<;++k)
if (i-a[k]>=)
dp1[i][j]+=(-dp2[i-a[k]][j])/20.0;
else
dp1[i][j]+=(-dp2[i][j])/20.0;
dp2[i][j]=;
for (int k=;k<;++k)
{
double temp=;
for (int l=;l<=;++l)
if (j-a[k+l]>=)
temp+=(-dp1[i][j-a[k+l]])/3.0;
else
temp+=(-dp1[i][j])/3.0;
if (temp>dp2[i][j]) dp2[i][j]=temp;
}
if (i> && j>) break;
}
}
}
int main()
{
int n;
solve();
while (scanf("%d",&n) && n)
{
printf("%.12f %.12f\n",dp1[n][n],dp2[n][n]);
} return ;
}
poj3876 darts的更多相关文章
- 日本DARTS 支撑的一系列应用项目
DARTS是多学科空间科学数据平台,例如天体物理.太阳物理.太阳物理.月球与行星科学和微重力科学.在此数据支撑下,有许多应用. 1.http://wms.selene.darts.isas.jaxa. ...
- Project Euler 109 :Darts 飞镖
Darts In the game of darts a player throws three darts at a target board which is split into twenty ...
- 4063: [Cerc2012]Darts
4063: [Cerc2012]Darts Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 85 Solved: 53[Submit][Status] ...
- 论文笔记:DARTS: Differentiable Architecture Search
DARTS: Differentiable Architecture Search 2019-03-19 10:04:26accepted by ICLR 2019 Paper:https://arx ...
- 论文笔记系列-DARTS: Differentiable Architecture Search
Summary 我的理解就是原本节点和节点之间操作是离散的,因为就是从若干个操作中选择某一个,而作者试图使用softmax和relaxation(松弛化)将操作连续化,所以模型结构搜索的任务就转变成了 ...
- POJ-1959 Darts
Darts Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 1286 Accepted: 741 Description Back ...
- UVALive 6262 Darts
Description Consider a game in which darts are thrown at a board. The board is formed by 10 circles ...
- DARTS代码分析(Pytorch)
最近在看DARTS的代码,有一个operations.py的文件,里面是对各类点与点之间操作的方法. OPS = { 'none': lambda C, stride, affine: Zero(st ...
- ZOJ3720 Magnet Darts(点在多边形内)
第一道点在多边形内的判断题,一开始以为是凸的.其实题意很简单的啦,最后转化为判断一个点是否在一个多边形内. 如果只是简单的凸多边形的话,我们可以枚举每条边算下叉积就可以知道某个点是不是在范围内了.但对 ...
随机推荐
- Ansible 运维自动化 ( 配置管理工具 )
背景 出差背景,要搞项目的自动化部署.因为只直接对接生产分发,机器又非常多,这样以往使用的bat只能作为应急方案了,还是得考虑使用专业化的工具来做这个事情! 当下有许多的运维自动化工具( 配置管理 ) ...
- python基础(9):文件处理
很多软件都会有有对文件处理的功能.今天我们就来学习文件处理. 文件处理 打开文件时,需要指定文件路径和以何等方式打开文件,打开后,可以将结果赋值给一个变量,这个变量我们称为句柄.这样我们就可以通过这个 ...
- HTTP权威指南-连接管理
现在已经开始学习到第四章咯,坚持就是胜利哟~!ok,废话少说,继续写笔记. 本章中我们要介绍到HTTP的连接.好,现在有几个问题,我列出来了,带着这几个问题,我们进入本章的学习. 1.HTTP是如何使 ...
- YARN笔记——技术点汇总
目录 · 概况 · 原理 · 资源调度器分类 · YARN架构 · ResourceManager · NodeManager · ApplicationMaster · Container · YA ...
- tomcat 与 java web中url路径的配置以及使用规则详情(长期更新)
首先我们看一下在myeclipse中建立的java web项目的结构 在这里我们需要注意这个webroot也就是我们在tomcat里的webapp里面的应用 之所以每一个项目都有这个webroot,是 ...
- js验证15位或18位身份证
本篇文章是本人在网上搜集了一些验证,然后又个人进行一定修改的关于身份证的验证,欢迎修改指正..... function IdCardValidateRule(idCard) { var tip; ...
- MyBatis String类型传递参数注意事项
Mybatis查询sql传入一个字符串传参数,报There is no getter for property named 'ids' in 'class java.lang.String'. 后来改 ...
- MySQL-InnoDB引擎
InnoDB存储引擎支持事务,其设计目标主要面向在线事务(OLTP)应用,其特点是: 行锁设计,支持外键,并支持类似于Oracle的非锁定读,即默认读取操作不会产生锁,从MySQL5.5.8 开始,I ...
- The method makeText(Context, CharSequence, int) in the type Toast is not applicable for the arguments (new View.OnClickListener(){}, String, int)
package comxunfang.button; import android.support.v7.app.ActionBarActivity; import android.os.Bundle ...
- AngularJS--购物车全选/取消全选功能实现
刚学习angularJS,于是练习写了一个类似于购物车的全选/取消全选的功能,主要实现的功能有: 1.勾选全选checkbox,列表数据全部被勾选,取消同理,用ng-model实现双向绑定: 2.选中 ...