To Bet or Not To Bet

Description

Alexander Charles McMillan loves to gamble, and during his last trip to the casino he ran across a new game. It is played on a linear sequence of squares as shown below.

A chip is initially placed on the Start square. The player then tries to move the chip to the End square through a series of turns, at which point the game ends. In each turn a coin is fl
ipped: if the coin is heads the chip is moved one square to the right and if the coin is tails the chip is moved two squares to the right (unless the chip is one square away from the End square, in which case it just moves to the End square). At that point, any instruction on the square the coin lands on must be followed. Each instruction is one of the following:
1. Move right n squares (where n is some positive integer)
2. Move left n squares (where n is some positive integer)
3. Lose a turn
4. No instruction
After following the instruction, the turn ends and a new one begins. Note that the chip only follows the instruction on the square it lands on after the coin flip. If, for example, the chip lands on a square that instructs it to move 3 spaces to the left, the move is made, but the instruction on the resulting square is ignored and the turn ends. Gambling for this game proceeds as follows: given a board layout and an integer T, you must wager whether or not you think the game will end within T turns.
After losing his shirt and several other articles of clothing, Alexander has decided he needs professional help-not in beating his gambling addiction, but in writing a program to help decide how to bet in this game.
Input

Input will consist of multiple problem instances. The first line will consist of an integer n indicating the number of problem instances. Each instance will consist of two lines: the first will contain two integers m and T (1 <= m <= 50, 1 <= T <= 40), where m is the size of the board excluding the Start and End squares, and T is the target number of turns. The next line will contain instructions for each of the m interior squares on the board. Instructions for the squares will be separated by a single space, and a square instruction will be one of the following: +n, -n, L or 0 (the digit zero). The first indicates a right move of n squares, the second a left move of n squares, the third a lose-a-turn square, and the fourth indicates no instruction for the square. No right or left move will ever move you off the board.
Output

Output for each problem instance will consist of one line, either
Bet for. x.xxxx
if you think that there is a greater than 50% chance that the game will end in T or fewer turns, or
Bet against. x.xxxx
if you think there is a less than 50% chance that the game will end in T or fewer turns, or
Push. 0.5000
otherwise, where x.xxxx is the probability of the game ending in T or fewer turns rounded to 4 decimal places. (Note that due to rounding the calculated probability for display, a probability of 0.5000 may appear after the Bet for. or Bet against. message.)
Sample Input

5
4 4
0 0 0 0
3 3
0 -1 L
3 4
0 -1 L
3 5
0 -1 L
10 20
+1 0 0 -1 L L 0 +3 -7 0
Sample Output

Bet for. 0.9375
Bet against. 0.0000
Push. 0.5000
Bet for. 0.7500
Bet for. 0.8954

0

1个回答

0
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
核磁数据处理: FSL系列之bet命令
bet命令用于脑组织的提取.有GUI和命令行两种调用方式. n下图是bet的GUI界面. 在shell中输入命令Bet就可以启动bet的GUI界面了. 界面非常简单,只需要制定输入图像,设置图像密度阈值f, 选择bet命令执行的方式:Run standard brain extraction using bet2 或者其他. 点击Go就可以运行得到结果了.nn n命令行调用bet最典型的格式为:n...
To Bet or Not To Bet
DescriptionnnAlexander Charles McMillan loves to gamble, and during his last trip to the casino he ran across a new game. It is played on a linear sequence of squares as shown below. n![](http://poj.org/images/1644_1.jpg)nnA chip is initially placed on the Start square. The player then tries to move the chip to the End square through a series of turns, at which point the game ends. In each turn a coin is fl nipped: if the coin is heads the chip is moved one square to the right and if the coin is tails the chip is moved two squares to the right (unless the chip is one square away from the End square, in which case it just moves to the End square). At that point, any instruction on the square the coin lands on must be followed. Each instruction is one of the following: n1. Move right n squares (where n is some positive integer) n2. Move left n squares (where n is some positive integer) n3. Lose a turn n4. No instruction nAfter following the instruction, the turn ends and a new one begins. Note that the chip only follows the instruction on the square it lands on after the coin flip. If, for example, the chip lands on a square that instructs it to move 3 spaces to the left, the move is made, but the instruction on the resulting square is ignored and the turn ends. Gambling for this game proceeds as follows: given a board layout and an integer T, you must wager whether or not you think the game will end within T turns. nAfter losing his shirt and several other articles of clothing, Alexander has decided he needs professional help-not in beating his gambling addiction, but in writing a program to help decide how to bet in this game.nInputnnInput will consist of multiple problem instances. The first line will consist of an integer n indicating the number of problem instances. Each instance will consist of two lines: the first will contain two integers m and T (1 <= m <= 50, 1 <= T <= 40), where m is the size of the board excluding the Start and End squares, and T is the target number of turns. The next line will contain instructions for each of the m interior squares on the board. Instructions for the squares will be separated by a single space, and a square instruction will be one of the following: +n, -n, L or 0 (the digit zero). The first indicates a right move of n squares, the second a left move of n squares, the third a lose-a-turn square, and the fourth indicates no instruction for the square. No right or left move will ever move you off the board.nOutputnnOutput for each problem instance will consist of one line, either nBet for. x.xxxx nif you think that there is a greater than 50% chance that the game will end in T or fewer turns, or nBet against. x.xxxx nif you think there is a less than 50% chance that the game will end in T or fewer turns, or nPush. 0.5000 notherwise, where x.xxxx is the probability of the game ending in T or fewer turns rounded to 4 decimal places. (Note that due to rounding the calculated probability for display, a probability of 0.5000 may appear after the Bet for. or Bet against. message.)nSample Inputnn5n4 4n0 0 0 0n3 3n0 -1 Ln3 4n0 -1 Ln3 5n0 -1 Ln10 20n+1 0 0 -1 L L 0 +3 -7 0nSample OutputnnBet for. 0.9375nBet against. 0.0000nPush. 0.5000nBet for. 0.7500nBet for. 0.8954
sMRI剥脑壳--基于FSL_BET
1.终端输入fsl后打开BETnnnn输入图像位置,生成图像位置,设置图像密度阈值f(f值越小,切割大脑轮廓设定越大), 选择bet执行算法,点击Go运行nnnn2.参数选择(点击Advanced options)nn-f&lt;f&gt; fractional intensity threshold (0-&gt;1); default=0.5; smaller values give la...
使用bet2工具进行颅骨去除操作
使用FSL下的bet2工具n$ bet2 &amp;lt;input&amp;gt; &amp;lt;output&amp;gt; [options]n$ bet2 T1.nii.gz skull_brain.nii.gz -f 0.15nn使用linux下parallel操作,并行去除颅骨操作nparallel --xapply bet2 {1} ./{2}/skull_brain.n...
bat批处理编程基本语法(1)
在Windows下,可以用cmd命令行进行一些操作,而有一种.bat格式的文件,将这些命令给过程化,这就是bat批处理编程。n比如我们在记事本中写下如下两行:nnn然后在命令行中运行如下命令:nnn可以看到它自动地Ping了百度和小米的网站,而不用我去输两次Ping命令,这就是批处理程序。n批处理的基本语法n1.echon作用类似于C语言的printf,可以在控制台中进行打印。
BET去脑壳算法 欢迎下载
讲述BET去脑壳算法 BET去脑壳算法 欢迎下载
Bet(思维
题目描述 nJosnch星球是一个赌博之风盛行的星球。每个人一出生就有一定数额的钱,之后的所有收入只能由赌博获得(OMG,如果RP不好,输光了所有的钱。。。)假设赌博公司的某场赌博有 N 个结果,每个结果能获得的赔率比分别是 a[1],a[2]…a[N]。假设现在XXX有 X 块钱,问他选择怎样的策略才能使得最坏情况下回报最大?假设 N 个结果中只有一个是有回报的,X块钱必须全部用在这次赌博上,赔率
Bet(赌)小程序 (codes)
yuanma 原码 另一个jar文件的原码 初学java 随手编来 for循环 输入 输出 控制台
投机笔记:DICE,POKER,BET,FARM等项目简要分析以及后续策略
n n n DICEn最近一周dice的成交量都稳定在200万以上,当然跟活动有关系,币价也稳步上升。nnnnnnnnnDICE 在减产到6.25x之后就再也没有操作了,一直持仓分红。个人认为DICE已经形成马太效应,也很有可能成为EOS DAPP中的币安,所以暂时持仓不会变动,静静的等着它涨上天就好了。nnPOKERn之前POKER的仓位太重,在低点的的时候出掉了大...
Bet(赌)小程序
bet 小程序 小的不能再小了 此乃jar文档 原码见另一个java文件
周志华 《机器学习》之 第三章(线性模型)概念总结
阅读之后,根据周志华老师对本章节的安排,首先从线性模型的基本形式入手,逐渐引入线性回归、对数几率回归、线性判别分析(LDA)、多分类学习等多种线性模型,最后针对类别不平衡问题总结了一些相关的解决思路 n1)线性模型的基本形式 n一般用向量形式写成 f(x)=wTx+bf(x) = w^Tx+b n线性模型形式简单、易于建模,却蕴涵着机器学习中的一些重要的基本思想。许多功能更为强大的线性模型(nonl
MCE公司:揭秘SPOP突变前列腺癌耐药机制
n前列腺癌是威胁全球男性的主要癌症之一,存在显著的肿瘤异质性,产生耐药也不尽相同。近年来的研究揭示了其SPOP突变亚型的作用机制,并由此给出一些建设性的治疗建议。nnn 前列腺癌是威胁全球男性的主要癌症之一,且影响其发生发展的因素复杂多样,存在显著的肿瘤异质性,产生耐药也不尽相同。在前列腺癌基因突变样本中,SPOP基因点突变存在于在大约10%。然而BET蛋白是近年来抗肿瘤药物设计的热门靶点,和SP...
远控程序远程总控段
My97 DatePickeMy97 DatePicker日期控件4.8 Bet沙发股份公告
存储过程写法
存储过程不是经常用到,但是有时负责业务需要用到,每次都去百度,这次记一下,方便下次用到,可以快速定位.rn下面的实例写的清楚,可以参考下rnBEGINn #按天拉取(ds_fenfen_lotto)的数据到报表(ds_report)表中n DECLARE t_error INTEGER;#出错标识n DECLARE done INTEGER;#结束标识nn DECLARE r_id BIGINT(
Guess a number! (二分答案)
A TV show called “Guess a number!” is gathering popularity. The whole Berland, the old and the young, are watching the show.nnThe rules are simple. The host thinks of an integer y and the participants
tomcat linux 开机自启动
n#!/bin/bash## tomcat6      This shell script takes care of starting and stopping Tomcat## chkconfig: - 80 20#### BEGIN INIT INFO# Provides: tomcat6# Required-Start: $network $syslog# Required-Stop: $...
你如何在 Eos bet 上,每天赚10个eos
n n n 看到题目,很多人的第一想法是水手哥真能吹。但水哥要告诉你的是,只要你有耐心,每天赚10个是可以做到的。而亏是因为大部分人都是想着靠着赌博致富,就是这个想法导致许多人倾家荡产。根据最新的数据统计,在eos基础上开发的dapp已经超过一百个。大部分都是菠菜类游戏,前几天bet dice超过了币安的交易量,可见菠菜类游戏之火爆程度。nnnnnn那么如何在bet上...
【HPUoj】Bet(数论)
题目链接:点击打开链接rnrnrnrn问题 B: Betrn时间限制: 1 Sec 内存限制:rn 128 MBrnrn提交: 1  解决:rn 1  状态rnrn题目描述rnrnJosnch星球是一个赌博之风盛行的星球。rn每个人一出生就有一定数额的钱,之后的所有收入只能由赌博获得(OMG,如果RP不好,输光了所有的钱。。。)rn假设赌博公司的某场赌博有 N 个结果,每个结果能获得的赔率比分别是
简单代码使用迁移学习识别8种不同的鱼,准确率95%
数据集下载:https://www.kaggle.com/c/the-nature-conservancy-fisheries-monitoring/datann环境搭建:nn使用anaconda安装指定版本的keras:nnconda install -c https://conda.anaconda.org/jaikumarm keras (keras不能大于2.2.0)nn nn导入包:nn...
Bet 【期望】+【gcd】
Betn时间限制: 1 Sec 内存限制:n 128 MBnn nnJosnch星球是一个赌博之风盛行的星球。n每个人一出生就有一定数额的钱,之后的所有收入只能由赌博获得(OMG,如果RP不好,输光了所有的钱。。。)n假设赌博公司的某场赌博有 N 个结果,每个结果能获得的赔率比分别是 a[1],a[2]...a[N]。n假设现在XXX有 X 块钱,问他选择怎样的策略才能使得最坏情
BRD4文献 BRD4最新研究 相关文献
BRD4全称为bromodomain-containing protein 4,即溴结构域蛋白4,属于BET家族成员。BET溴结构域(bromodomain and extra-terminal domain)包含四种蛋白,即BRD2、BRD3、BRD4和BRDT。BET具有保守的模块化结构:包括两段N-末端串联BRD效应模块(BD1和BD2),一段额外的末端基团(ET),几组保守的区域(A,B,SEED区域)和C-末端区域(CTM)(图1)。
博彩公司叱咤英伦,中美体育界共盼博彩合法化
n n n 同去年相比,今年的中国体育产业或许就不显得那么生机勃勃了。虽然资本的投入依然不减,但大众消费的习惯却不会因为资本的热情而在短期内发生太多的改变。中国体育产业要想迎来真正的爆发,仍需等待C端市场的崛起。抛开体育用品等体育产业外延概念不谈,今年与体育大众消费市场相关的领域都备受关注。除了观赛相关的媒体转播版权费继续高涨外,线下参与相关的体育培训以及以马拉松为代...
【技巧-二分查找】ACdreamOJ Bet 1066
BetrnrnTime Limit: 2000/1000MS (Java/Others) Memory Limit: 128000/64000KB (Java/Others)rnrnSubmit Statistic Nextrn ProblemrnrnProblem DescriptionrnrnJosnch星球是一个赌博之风盛行的星球。rn每个人一出生就有一定数额的钱,之后的所有收入只能由赌博获
调用CHM帮助文件的几种方法(含全部源码)
一个应用程序不论编制得如何完美,在很多情况下用户还是会对如何使用它提出问题。 Visual Basic 提供了对两种不同帮助系统的支持:传统的 Windows 帮助系统 (WinHelp)和新的 HTML 帮助(CHM帮助)。当我们制作好帮助文件后,就需要在程序的适当位置编写代码进行调用,本文将讨论几种在程序中调用CHM帮助文件的方法。
360浏览器中页面打开如何默认极速模式
360浏览器中页面打开如何默认极速模式
linux环境举例Bet系统搭建手册
linux环境举例Bet系统搭建手册,希望给学习Linux做参考,给一点帮助吧
Lucky Bet中奖名单出炉
n n n nnnnn n n nIOST测试网Everest 0.5自上线以来收获了广泛关注和一致好评,demo小游戏“Lucky Bet”也广受欢迎,参与人数众多。在大家的热情参与和互动之下,我们的测试网经受住了考验,运转一切正常。nnnnnn7月1日24时,我们的有奖参与活动已经结束,现将...
Bet Dice 的镰刀到底有多快?
n n n 早上一觉睡醒,我就迫不及待的开BET DICE网站,去看下昨天忍痛花了2 EOS 买的彩票,到底有没有能提车。nnnnnn失望!这个是不是诓人的啊!怎么又是一个人中多个奖,看上面的图,第二轮彩票的中奖名单,一共五个,被3个人包揽了。没中就没中,还是看看我离大奖有多少距离吧,毕竟也是花了2 EOS的,两天的饭钱啊。找了半天,我就想看下我买的彩票号是多少,抱歉...
float与byte数组的相互转换,d lang V1
[code=&quot;java&quot;]import tango.io.Stdout;rnrnvoid ConvertFloatToBytes(float Value,inout byte[] Bytes)rn{rn uint ByteVal1, ByteVal2, ByteVal3, ByteVal4; rn asmrn {rn mov EAX, Value;rn and EAX, 0xFF000000...
教你一步一步实现图标无缝变形切换
在上一篇文章[《酷炫的Activity切换动画,打造更好的用户体验 》](http://blog.csdn.net/huachao1001/article/details/51659963)中,我们感受到了过渡切换动画带来的不一样的用户体验。如何你还意犹未尽,那么今天我们再体验一把图标切换动画。先来个效果图,让你更有动力往下看(PS:以下gif是放慢了的动画,另外gif丢帧导致不流畅,各位不要觉得很卡哈~)
Byshell 远程后门控制 1.09 C++源码.rar
Byshell 远程后门控制 1.09 C++源码.rar
赌场21点游戏
在赌场21点游戏中,玩家可以通过计算牌桌上已经发放的卡牌的高低值来让自己在游戏中保持优势,这就叫21点算法。rn根据下面的表格,每张卡牌都分配了一个值。如果卡牌的值大于0,那么玩家应该追加赌注。反之,追加少许赌注甚至不追加赌注。rnrnrnrnrnCount ChangernCardsrnrnrnrnrn+1rn2, 3, 4, 5, 6rnrnrn0rn7, 8, 9rnrnrn-1rn10,
猜数游戏 c++源代码
guessing and betting number game The user starts with 100 dollars, and is able to bet and guess until they quit or have no more money. In each turn, they are asked for a bet. If they enter 0, then the program should give a farewell message and quit. The bet must be positive and within their available balance, If they enter incorrectly, the program should set the bet to their balance and tell them this. Once a bet is entered, they must pick a number between 1 and 10 (you do not need to errorcheck or correct this). This guess is then compared to a number the computer randomly generates each time (also between 1 and 10). If the guess is correct, the user wins the amount of their bet. If the guess is incorrect, the user will lose their bet divided by 5 and multiplied by the distance from the correct number - e.g. if the bet is 50, the computer’s number is 5 and the user guesses 7, then the user will lose 20 dollars( 50/5 * (7-5) = 20 ). However, they should not lose more than their balance, so if their balance is 50, the bet is 40, the computer’s number is 1 and the user guesses 10, (40/5 * (10-1) = 72 > 50 )then they should lose 50. After each turn, the program should display that turn's winnings (or loss amount) and the new balance,and then repeat the game until the user either quits or has no money left. Dollar values should be formatted in the standard way with two decimal places and a $ in front. Sample output from the program is below. You should make your program match this exactly (except for your name). An appropriate welcome message with your name in it should be shown at the start of the program. Assignment 1 : Guessing Game Written by yourname Please enter your bet (up to $100.00): $50 Guess a number between 1 and 10: 5 Correct! You win $50.00 Your new balance is $150.00 Please enter your bet (up to $150.00): $200 Your bet is $150.00 Guess a number between 1 and 10: 6 Wrong! The computer chose: 4 You lose $60.00 Your new balance is $90.00 Please enter your bet (up to $90.00): $80 Guess a number between 1 and 10: 1 Wrong! The computer chose: 7 You lose $90.00 Thank you for playing! Press any key to continue . . . Another Sample: CP1200 Guessing Game Written by Lindsay Ward Please enter your bet (up to $100.00): $-20 Your bet is $100.00 Guess a number between 1 and 10: 5 Wrong! The computer chose: 2 You lose $60.00 Your new balance is $40.00 Please enter your bet (up to $40.00): $10.50 Guess a number between 1 and 10: 12 Wrong! The computer chose: 2 You lose $21.00 Your new balance is $19.00 Please enter your bet (up to $19.00): $0 Thank you for playing! Press any key to continue . . . srand( static_cast<int>(time(0))) ; 初始化 computerNumber = 1 + rand( ) % 10 ; 产生随机数 cout << fixed << setprecision(2) ; 控制输出显示2位小数
FSL5.0使用教程
我用的是Ubantu16.04,安装的是fsl-completenn首先是BET 模块nnnn我主要是用它来去掉非脑组织的,输入原图的路径以及输出保存的路径,点击Go 运行一段时间非脑祖宗就去掉了nnnn第二个模块是FLIRT模块,它是用来变换的,这里面是线性变换中的放射变化nnnn这里的Renference image需要提前下载安装好,百度fsl atlas fsl's MNI152 stan...
使用betwenn join 求 dept_emp 表中计算每个部门每个月的在职人数
如题所示 ,下面是表结构nroot@mysql3306.sock&amp;amp;amp;amp;amp;amp;amp;gt;[employees]&amp;amp;amp;amp;amp;amp;amp;gt;desc dept_emp;n+-----------+---------+------+-----+---------+-------+n| Field | Type | Null | Key | Default | Extra |n+-----------+---------+-
后缀.{callmegoat@PROTONMAIL.COM}CMG勒索病毒处理方式,.COM}CMG勒索病毒数据恢复方法
本文旨在向您展示如何删除.{CALLMEGOAT@PROTONMAIL.COM}CMG病毒以及如何恢复文件,并使用添加的.{CALLMEGOAT@PROTONMAIL.COM}CMG文件扩展名进行加密。nn安全人员检测到另一个勒索软件,这次使用.{CALLMEGOAT@PROTONMAIL.COM}CMG文件扩展名。与其他类型的病毒一样,勒索软件旨在加密受其感染的计算机上的文件,其主要思想是让受害...
网上收集的200多个Google Earth地标库文件+Google Earth Pro V4.0.1693 绿色汉化版.rar
google earth 地标库
js脚本添加书签到收藏夹
javascript:window.external.addFavorite('http://localhost:8080/indumis_V_aix_1.2.3','111')
常见符号发音表
一些常见符号,主要是数学符号的发音。 如:1)Α α alpha a:lf 阿尔法 角度;系数 2)Β β beta bet 贝塔 磁通系数;角度;系数
2019年BET公司面试题目大汇总
【1】百度提前批一面(c++开发):n1.关键字static作用,函数加static和不加static区别n2.const关键字作用,const和宏定义有什么区别,用哪个?(宏定义太多会导致代码膨胀)n3.虚函数是如何实现的?n4.线程和进程的区别,线程如何实现同步和通信,进程如何实现通信?n5.了解哪些线程模型?n6.手写二叉树中序遍历递归和非递归。n7.socket如何进行通信?n8.poll...
文章热词 机器学习教程 Objective-C培训 交互设计视频教程 颜色模型 设计制作学习
相关热词 mysql关联查询两次本表 native底部 react extjs glyph 图标 怎么学习互联网大数据 村干部学习大数据心得