博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Flipping Coins Gym - 101606F
阅读量:4114 次
发布时间:2019-05-25

本文共 1060 字,大约阅读时间需要 3 分钟。

题意:Here’s a jolly and simple game: line up a row of N identical coins, all with the heads facingdown onto the table and the tails upwards, and for exactly K times take one of the coins, toss itinto the air, and replace it as it lands either heads-up or heads-down. You may keep all of thecoins that are face-up by the end.Being, as we established last year, a ruthless capitalist, you have resolved to play optimally towin as many coins as you can. Across all possible combinations of strategies and results, whatis the maximum expected (mean average) amount you can win by playing optimally?

给你一些硬币,硬币的初始状态都是正面向下,反面向上,现在你可以每次任取一个硬币把它抛向空中,你可以进行k次操作,问你k次操作之后硬币正面向上的最大数学期望。

思路:一共进行k次操作,每次我们都可以任取一个硬币把它抛一次,由于题目中说是让求最大的数学期望,那么我们抛的时候取正面向下的可以得到最大的数学期望,我们定义一个状态dp[i][j],表示抛i次其中有j个硬币正面向上的概率。

那么我们可以得到转移方程:

dp[i+1][j]+=dp[i][j]*0.5;

dp[i+1][j+1]+=dp[i][j]*0.5;

当j=n时

dp[i+1][n]+=dp[i][n]*0.5;

dp[i+1][n-1]+=dp[i][n]*0.5;

注意dp[0][0]=1;

#include 
using namespace std;const int maxn=450;double dp[maxn][maxn];int main(){ int n,k; cin>>n>>k; for(int i=0; i

转载地址:http://ybgsi.baihongyu.com/

你可能感兴趣的文章
idea的安装以及简单使用
查看>>
Windows mysql 安装
查看>>
python循环语句与C语言的区别
查看>>
Vue项目中使用img图片和background背景图的使用方法
查看>>
vue 项目中图片选择路径位置static 或 assets区别
查看>>
vue项目打包后无法运行报错空白页面
查看>>
Vue 解决部署到服务器后或者build之后Element UI图标不显示问题(404错误)
查看>>
element-ui全局自定义主题
查看>>
facebook库runtime.js
查看>>
vue2.* 中 使用socket.io
查看>>
openlayers安装引用
查看>>
js报错显示subString/subStr is not a function
查看>>
高德地图js API实现鼠标悬浮于点标记时弹出信息窗体显示详情,点击点标记放大地图操作
查看>>
初始化VUE项目报错
查看>>
vue项目使用安装sass
查看>>
HTTP和HttpServletRequest 要点
查看>>
在osg场景中使用GLSL语言——一个例子
查看>>
关于无线PCB中 中50欧姆的特性阻抗的注意事项
查看>>
Spring的单例模式源码小窥
查看>>
后台服务的变慢排查思路(轻量级应用服务器中测试)
查看>>