hdu 4089 Activation (概率dp 手动消元)

探讨玩家在排队激活游戏过程中,遇到服务器故障的概率问题。通过动态规划算法解决特定条件下服务器故障概率的计算。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Activation

Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1562    Accepted Submission(s): 592


Problem Description
After 4 years' waiting, the game "Chinese Paladin 5" finally comes out. Tomato is a crazy fan, and luckily he got the first release. Now he is at home, ready to begin his journey.
But before starting the game, he must first activate the product on the official site. There are too many passionate fans that the activation server cannot deal with all the requests at the same time, so all the players must wait in queue. Each time, the server deals with the request of the first player in the queue, and the result may be one of the following, each has a probability:
1. Activation failed: This happens with the probability of p1. The queue remains unchanged and the server will try to deal with the same request the next time.
2. Connection failed: This happens with the probability of p2. Something just happened and the first player in queue lost his connection with the server. The server will then remove his request from the queue. After that, the player will immediately connect to the server again and starts queuing at the tail of the queue.
3. Activation succeeded: This happens with the probability of p3. Congratulations, the player will leave the queue and enjoy the game himself.
4. Service unavailable: This happens with the probability of p4. Something just happened and the server is down. The website must shutdown the server at once. All the requests that are still in the queue will never be dealt.
Tomato thinks it sucks if the server is down while he is still waiting in the queue and there are no more than K-1 guys before him. And he wants to know the probability that this ugly thing happens.
To make it clear, we say three things may happen to Tomato: he succeeded activating the game; the server is down while he is in the queue and there are no more than K-1 guys before him; the server is down while he is in the queue and there are at least K guys before him.
Now you are to calculate the probability of the second thing.
 

Input
There are no more than 40 test cases. Each case in one line, contains three integers and four real numbers: N, M (1 <= M <= N <= 2000), K (K >= 1), p1, p2, p3, p4 (0 <= p1, p2, p3, p4 <= 1, p1 + p2 + p3 + p4 = 1), indicating there are N guys in the queue (the positions are numbered from 1 to N), and at the beginning Tomato is at the Mth position, with the probability p1, p2, p3, p4 mentioned above.
 

Output
A real number in one line for each case, the probability that the ugly thing happens.
The answer should be rounded to 5 digits after the decimal point.
 

Sample Input
  
2 2 1 0.1 0.2 0.3 0.4 3 2 1 0.4 0.3 0.2 0.1 4 2 3 0.16 0.16 0.16 0.52
 

Sample Output
  
0.30427 0.23280 0.90343
 

Source
 

题意:
有n个人排队等着在官网上激活游戏。Tomato排在第m个。
对于队列中的第一个人。有一下情况:
1、激活失败,留在队列中等待下一次激活(概率为p1)
2、失去连接,出队列,然后排在队列的最后(概率为p2)
3、激活成功,离开队列(概率为p3)
4、服务器瘫痪,服务器停止激活,所有人都无法激活了。
求服务器瘫痪时Tomato在队列中的位置<=k的概率。

思路来源于:点击打开链接

思路:
dp[i][j]表示还有i个人,他在第j个位置达到目标状态的概率。
if(j==1)            dp[i][1]=dp[i][1]*p1+dp[i][i]*p2+p4;
if(j>=2&&j<=k)      dp[i][j]=dp[i][j]*p1+dp[i][j-1]*p2+dp[i-1][j-1]*p3+p4;
if(j>k)             dp[i][j]=dp[i][j]*p1+dp[i][j-1]*p2+dp[i-1][j-1]*p3; 
化简一下:
if(j==1)            dp[i][1]=dp[i][i]*p2/(1-p1)+p4/(1-p1);  (1)
if(j>=2&&j<=k)      dp[i][j]=dp[i][j-1]*p2/(1-p1)+dp[i-1][j-1]*p3/(1-p1)+p4/(1-p1);
if(j>k)             dp[i][j]=dp[i][j-1]*p2/(1-p1)+dp[i-1][j-1]*p3/(1-p1);

在求dp[i][j]的时候i-1的状态全部知道,只用考虑第i层,因为dp[i][1]会推到dp[i][i],所以会形成环,需要手动化简,注意i不变,所以涉及到的式子只有i个,可以迭代找出dp[i][i]与dp[i][1]的关系,然后带入(1)式,解出dp[i][i],然后就可以求dp[i][j]了。还要注意的一点是p4很小的时候概率为0。

代码:
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
#include <stack>
#include <vector>
#include <set>
#include <queue>
#define maxn 2005
#define MAXN 400005
#define mod 1000000007
#define INF 0x3f3f3f3f
#define pi acos(-1.0)
#define eps 1e-6
typedef long long ll;
using namespace std;

int n,m,k;
double dp[maxn][maxn],p1,p2,p3,p4;

void solve()
{
    int i,j;
    double p21=p2/(1-p1),p31=p3/(1-p1),p41=p4/(1-p1),pp,tt;
    dp[1][1]=p4/(1-p1-p2);
    for(i=2;i<=n;i++)
    {
        pp=1;
        tt=0;
        for(j=2;j<=k&&j<=i;j++)
        {
            pp*=p21;
            tt*=p21;
            tt+=p31*dp[i-1][j-1]+p41;
        }
        for(j=k+1;j<=i;j++)
        {
            pp*=p21;
            tt*=p21;
            tt+=p31*dp[i-1][j-1];
        }
        dp[i][i]=(tt*(1-p1)+pp*p4)/(1-p1-pp*p2);
        dp[i][1]=p21*dp[i][i]+p41;
        for(j=2;j<=k&&j<i;j++)
        {
            dp[i][j]=p21*dp[i][j-1]+p31*dp[i-1][j-1]+p41;
        }
        for(j=k+1;j<i;j++)
        {
            dp[i][j]=p21*dp[i][j-1]+p31*dp[i-1][j-1];
        }
    }
    printf("%.5f\n",dp[n][m]);
}
int main()
{
    int i,j;
    while(~scanf("%d%d%d%lf%lf%lf%lf",&n,&m,&k,&p1,&p2,&p3,&p4))
    {
        if(p4<=eps)
        {
            printf("%.5f\n",0);
            continue ;
        }
        solve();
    }
    return 0;
}
/*
2 2 1 0.1 0.2 0.3 0.4
3 2 1 0.4 0.3 0.2 0.1
4 2 3 0.16 0.16 0.16 0.52
*/


内容概要:论文提出了一种基于空间调制的能量高效分子通信方案(SM-MC),将传输符号分为空间符号和浓度符号。空间符号通过激活单个发射纳米机器人的索引来传输信息,浓度符号则采用传统的浓度移位键控(CSK)调制。相比现有的MIMO分子通信方案,SM-MC避免了链路间干扰,降低了检测复杂度并提高了性能。论文分析了SM-MC及其特例SSK-MC的符号错误率(SER),并通过仿真验证了其性能优于传统的MIMO-MC和SISO-MC方案。此外,论文还探讨了分子通信领域的挑战、优势及相关研究工作,强调了空间维度作为新的信息自由度的重要性,并提出了未来的研究方向和技术挑战。 适合人群:具备一定通信理论基础,特别是对纳米通信和分子通信感兴趣的科研人员、研究生和工程师。 使用场景及目标:①理解分子通信中空间调制的工作原理及其优势;②掌握SM-MC系统的具体实现细节,包括发射、接收、检测算法及性能分析;③对比不同分子通信方案(如MIMO-MC、SISO-MC、SSK-MC)的性能差异;④探索分子通信在纳米网络中的应用前景。 其他说明:论文不仅提供了详细的理论分析和仿真验证,还给出了具体的代码实现,帮助读者更好地理解和复现实验结果。此外,论文还讨论了分子通信领域的标准化进展,以及未来可能的研究方向,如混合调制方案、自适应调制技术和纳米机器协作协议等。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值