2018CCPC 吉林 DThe Moon[概率dp/记忆化搜索]

本文探讨了一款名为《RandomSix》的FPS游戏中,玩家获取特定礼物“BetaPack”的数学模型。通过分析游戏机制,包括游戏胜利概率、物品掉落率及其随游戏进程的变化,文章详细解释了如何使用动态规划算法来计算获得物品所需平均游戏次数。

The Moon
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)
Total Submission(s): 359 Accepted Submission(s): 160
Special Judge

Problem Description
The Moon card shows a large, full moon in the night’s sky, positioned between two large towers. The Moon is a symbol of intuition, dreams, and the unconscious. The light of the moon is dim, compared to the sun, and only vaguely illuminates the path to higher consciousness which winds between the two towers.

Random Six is a FPS game made by VBI(Various Bug Institution). There is a gift named “Beta Pack”. Mr. K wants to get a beta pack. Here is the rule.
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.

Input
The first line contains testcase number T (T ≤ 100). For each testcase the first line contains an integer p (1 ≤ p ≤ 100).

Output
For each testcase print Case i : and then print the answer in one line, with absolute or relative error not exceeding 106.

Sample Input
2
50
100

Sample Output
Case 1: 12.9933758002
Case 2: 8.5431270393

题意:1.起初物品掉落率q=2%;

2.玩家进行一次游戏,有p的概率获胜。

3.如果获胜了,有q的概率掉落一个叫Beta Pack的物品。如果掉落,游戏结束,否则q+=2%

4.如果不获胜,q+=1.5%。

重复2和3直到游戏结束。

求得到一个物品 进行游戏场次的期望。

题解:可以知道当q=100的时候百分百可以得到该物品,此时期望为1/p,这道题可以转化为已知某一状态的期望值,求初始状态的期望值,游戏结束的期望=1+本轮获胜但未掉落物品的概率 * 下一状态游戏结束的期望 + 本轮不获胜 * 下一状态游戏结束的期望 + 本轮游戏结束的概率 * 0(因为本轮已经结束了嘛,所以下一状态结束的期望为0)
可以有两种写法:
1、容易想到的是记忆化搜索的写法:

#include<bits/stdc++.h>
using namespace std;
#define debug(x) cout<<#x<<" is "<<x<<endl;
typedef long long ll;
const int maxn=1e5+5;
double dp[105][205];
double dfs(int p,int q){
    if(q==200)return 100.0/p;
    if(dp[p][q])return dp[p][q];
    double Q=(double)q/200;
    double P=(double)p/100;
    return dp[p][q]=1+P*(1-Q)*dfs(p,min(200,q+4))+(1-P)*dfs(p,min(200,q+3))+P*Q*0;
}
int main(){
    int t;
    int cas=0;
    scanf("%d",&t);
    while(t--){
        int p;
        scanf("%d",&p);
        for(int i=0;i<105;i++){
            for(int j=0;j<205;j++){
                dp[i][j]=0;
            }
        }
        printf("Case %d: %.7f\n",++cas,dfs(p,4));
    }

    return 0;
}

2、dp写法

#include<bits/stdc++.h>
using namespace std;
#define debug(x) cout<<#x<<" is "<<x<<endl;
typedef long long ll;
const int maxn=1e5+5;
double dp[205];
int main(){
    int t;
    int cas=0;
    scanf("%d",&t);
    while(t--){
        int p;
        scanf("%d",&p);
        for(int i=0;i<205;i++)dp[i]=0;
        dp[200]=100.0/p;
        for(int i=199;i>=4;i--){
            dp[i]=1+(1-0.01*p)*dp[min(200,i+3)]+(1-0.005*i)*0.01*p*dp[min(200,i+4)]+0.01*p*0.005*i*0;
        }
        printf("Case %d: %.7f\n",++cas,dp[4]);
    }
    return 0;
}

内容概要:本文介绍了基于贝叶斯优化的CNN-LSTM混合神经网络在时间序列预测中的应用,并提供了完整的Matlab代码实现。该模型结合了卷积神经网络(CNN)在特征提取方面的优势与长短期记忆网络(LSTM)在处理时序依赖问题上的强大能力,形成一种高效的混合预测架构。通过贝叶斯优化算法自动调参,提升了模型的预测精度与泛化能力,适用于风电、光伏、负荷、交通流等多种复杂非线性系统的预测任务。文中还展示了模型训练流程、参数优化机制及实际预测效果分析,突出其在科研与工程应用中的实用性。; 适合人群:具备一定机器学习基基于贝叶斯优化CNN-LSTM混合神经网络预测(Matlab代码实现)础和Matlab编程经验的高校研究生、科研人员及从事预测建模的工程技术人员,尤其适合关注深度学习与智能优化算法结合应用的研究者。; 使用场景及目标:①解决各类时间序列预测问题,如能源出力预测、电力负荷预测、环境数据预测等;②学习如何将CNN-LSTM模型与贝叶斯优化相结合,提升模型性能;③掌握Matlab环境下深度学习模型搭建与超参数自动优化的技术路线。; 阅读建议:建议读者结合提供的Matlab代码进行实践操作,重点关注贝叶斯优化模块与混合神经网络结构的设计逻辑,通过调整数据集和参数加深对模型工作机制的理解,同时可将其框架迁移至其他预测场景中验证效果。
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值