2018ccpc吉林 问题 D: THE MOON 概率dp

题意:

Step 0. Let initial chance rate q = 2%.
Step 1. Player plays a round of the game with winning rate p%.
Step 2. If the player wins, then will go to Step 3 else go to Step 4.
Step 3. Player gets a beta pack with probability q. If he doesn't get it, let q = min(100%, q + 2%) and he will go to Step 1.
Step 4. Let q = min(100%, q + 1.5%) and goto Step 1.
Mr. K has winning rate p% , he wants to know what's the expected number of rounds before he needs to play.

题解:dp[i][j]表示 q为i,p为j时的期望次数,因为有一个1.5的存在,所以我们的q都乘10进行计算

dp[q][p]=1+1.0*p/100*(1-1.0*q/1000)*dp[min(q+20,1000)][p]+(100.0-p)/100*dp[min(q+15,1000)][p]

初始dp[1000][i]=100/i

#include<bits/stdc++.h>
using namespace std;
double dp[1010][110];
double dfs(int q,int p)
{
	if(dp[q][p]!=-1)return dp[q][p];
	dp[q][p]=1+1.0*p/100*(1-1.0*q/1000)*dfs(min(q+20,1000),p)+(100.0-p)/100*dfs(min(q+15,1000),p);
	return dp[q][p];
}
int main()
{
	for(int i=1;i<=1000;i++)
	{
		for(int j=1;j<=100;j++)
			dp[i][j]=-1;
	}
	for(int i=1;i<=100;i++)
		dp[1000][i]=100.0/i;
	int T,p;
	int nn=1;
	scanf("%d",&T);
	while(T--)
	{
		scanf("%d",&p);
		printf("Case %d: %.10f\n",nn++,dfs(20,p));
	}
	return 0;
}

 

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值