HDU4089-Activation(概率DP)

Linux系统监控实战:夜莺监控+categraf采集器配置全流程(附常见问题排查) 本文详细介绍了在Linux系统中使用夜莺监控和categraf采集器进行系统监控的全流程配置,包括环境准备、核心配置文件(如config.toml和procstat.toml)详解、服务集成与验证、高级监控配置实战以及常见问题排查。通过实战案例和优化建议,帮助运维人员快速构建高效的监控体系。 阅读详情

Activation

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


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
 

迭代终于有一点感觉了!

#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <cmath>
using namespace std;

const double eps = 1e-7;
const int maxn = 2000+10;
int n,m,k;
double dp[maxn][maxn];
double p1,p2,p3,p4;
double A[maxn];
double Pow[maxn];

int main(){
    while(~scanf("%d%d%d%lf%lf%lf%lf",&n,&m,&k,&p1,&p2,&p3,&p4)){
        if(p4<eps) {
            printf("0.00000\n");
            continue;
        }
        double p21 = p2/(1-p1);
        double p31 = p3/(1-p1);
        double p41 = p4/(1-p1);
        Pow[0] = 1;
        for(int i = 1; i <= n; i++) Pow[i] = Pow[i-1]*p21;

        dp[1][1] = p41/(1-p21);
        for(int i = 2; i <= n; i++){
            A[1] = p41;
            for(int j = 2; j <= i; j++){
                A[j] = p31*dp[i-1][j-1];
                if(j<=k) A[j] += p41;
            }
            double t = A[1]*Pow[i-1];
            for(int j = 2; j <= i; j++){
                t += A[j]*Pow[i-j];
            }
            dp[i][i] = t/(1-Pow[i]);
            dp[i][1] = p21*dp[i][i]+p41;
            for(int j = 2; j < i; j++)
                dp[i][j] = p21*dp[i][j-1]+A[j];
        }
        printf("%.5lf\n",dp[n][m]);
    }
    return 0;
}


2 海康视觉平台VisionMaster 上手系列:大纲及准备 海康视觉平台VisionMaster 大纲,课前准备 快速入门 工业机器视觉 机器视觉 阅读详情

相关推荐

ENVI哨兵一号数据处理

使用ENVI+SarScape处理哨兵数据

Rjjjjj11的博客 2万+

HDU--4089(概率DP)

2015-04-2122:22:23 题意:一队人排着队激活游戏,服务器每次对队首的人的要求进行处理,有4种可能:   (1)失败,概率p1 (2)失联,排到队末,概率p2 (2)成功,概率p3 (4)服务器崩溃,概率p4   一开始一队有n个人,某人排在第m个,问服务器崩溃时该人前面的人数 <= k-1 的概率。 思路:   一开始完全木有思路... TAT,看...

dingdi3021的博客 194

卫星动力学仿真模型开发之AI初试

以下是通过AI生成的一个简单的C语言仿真模型,用于模拟卫星的姿态、轨道动力学和运动学。该模型基于基本的物理公式,假设卫星在近地轨道上运行,并忽略了一些复杂的扰动因素(如大气阻力、太阳辐射压等)。姿态动力学描述了卫星绕其质心的旋转运动。轨道动力学描述了卫星在引力作用下的运动。姿态运动学描述了卫星姿态随时间的变化。

xspace的博客 569

HDU4089 Activation 概率DP

HDU 4089 Activation 概率DP 题目链接:[http://acm.hdu.edu.cn/showproblem.php?pid=4089] 题目大意: Tomato去排队激活游戏,每次对队首位置的人进行处理,处理时会产生四种情况: 激活失败,队伍不变,下次重新从队首的人开始处理,概率为p1 连接失败,队首的人排到队尾,下次从新的队首的人开始处理,概率为p2 激活成功,队首的人退...

qq_43710979的博客 255

SpringBoot3 + OAuth2.1实战:5分钟搞定授权码模式(含完整代码)

本文详细介绍了如何在SpringBoot3环境中快速实现OAuth2.1的授权码模式,包括环境配置、核心安全实现及完整代码示例。通过Spring Security集成,开发者可以高效构建企业级安全认证系统,解决版本兼容性问题,提升开发效率。

weixin_29216353的博客 141

Jetson AGX ORIN硬件初始化和环境部署

orin预安装了ubuntu20.04,只需开机,像重装系统一样设置用户信息即可,可以参考官网的教程[https://developer.nvidia.com/embedded/learn/get-started-jetson-agx-orin-devkit],官网提供了两种方式:一种是orin + 显示器,orin有提供DP接口,你需要准备一台显示器,最好也是有DP口的,因为我用DP转HDMI的连的,分辨率会受影响。确认安装的路径,一般直接回车安装在默认的 /home/你的名字/anaconda3。

TracyGC的博客 3836

hdu4089(概率DP)

题意:n个人排成一个队列,小明一开始排在第m个,可能出现四中情况:1、队列保持不变的概率p1; 2、第一个人排到最后一个的概率p2; 3、第一个人离开的概率p3;4、排队结束的概率p4. 求在排队结束时,小明排在前k个的概率。 思路:dp[i][j]表示一共i个人,小明排在第j个的排队结束的概率。状态转移: j==1:    dp[i][1]=p1*dp[i][1]+p2*dp[i][i]+

u013509299的专栏 787

保姆级教程:用Python+MM-Agent搭建自己的数学建模AI助手(支持GPT-4o/DeepSeek)

本文提供了一份详细的教程,教你如何使用Python和MM-Agent框架搭建数学建模AI助手,支持GPT-4o和DeepSeek-R1等LLM后端。从环境配置、HMML知识库集成到多LLM适配和建模流程实现,手把手教你构建智能建模系统,提升数学建模效率。

k6l7m8n9的博客 452

hdu4089 Activation

Activation Time Limit: 20000/10000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 879 Accepted Submission(s): 314 Problem Description After 4 years' waiting, t

习惯与规则决定命运 903

STM32F103xx / STM32F429VET6最小系统原理图

心血来潮想试一下STM32F4系列和F1系列在编程上有什么差别,手头没有开发板,本着能勤俭节约的原则自己先做一块看看能不能成,看了一下STM32F429VET6的芯片在F429xx中最便宜,对照着数据手册绘制了原理图画了PCB,目前打板中,焊接完如果跑不通回来修改文章。这里我们可以看到,VDD是标准工作电压,VDDA是模拟工作电压,且VDDA必须与VDD等电位,VBAT是备份工作电压,一般接纽扣电池电源,如果存在VREF+引脚,则要求VDDA-VREF+ < 1.2V。截图下来比较糊,不知道为什么。

m0_51294753的博客 1万+

17track单号查询逆向分析

这就说明该网站很有可能存在其它检测点,而检测本地替换最大可能的就是检测了代码格式化或者代码长度。也一样,要么导致网站卡死,要么会导致网页加载异常,这里可能就难到不少人了,让我们一步一步解决。而这个站主要是检测了代码格式化,无限循环检测造成了网站卡死,经多次测试发现检测点共三处。方法中代码很长,但是经调试后发现,它其实只返回一个固定的值,这里直接写死即可。同样的,虽然看起来很长,但是跟过之后就会发现流程很简单,这里主要就是对。追加了一些值,是一条很长的语句,整理代码。,核心流程也很简单,稍微跟一下就出来了,

pyzzd的博客 1624

hdu4089(公式推导)概率dp

题意:有n人都是仙剑5的fans,现在要在官网上激活游戏,n个人排成一个队列(其中主角Tomato最初排名为m),     对于队列中的第一个人,在激活的时候有以下五种情况:     1.激活失败:留在队列中继续等待下一次激活(概率p1)     2.失去连接:激活失败,并且出队列然后排到队列的尾部(概率p2)     3.激活成功:出队列(概率p3)     4.服务器瘫:服务器停止服

xiefubao的专栏 899

在 SAP BTP Cloud Foundry 环境中开发 SAP HANA 的完整实战路线图

SAP HANA Cloud迁移路径解析:从本地到云原生的数据库现代化 本文梳理了SAP HANA在Cloud Foundry环境中的架构定位和实施路径,针对不同起点的项目提供迁移建议。核心内容包括: SAP HANA Cloud在Cloud Foundry中的双重角色:既作为平台服务提供数据库实例,又通过HDI容器管理MTA应用中的数据库工件。 针对四类典型项目起点的迁移策略: 绿地项目:直接采用CAP+SAP HANA Cloud组合 已有HANA service或XS advanced项目:需对照兼容

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 266

概率dp-hdu-4089-Activation

题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=4089 题目意思: n个人排队尝试游戏,队首中有四种情况。 1、动作失败重新连,队列不变,概率为p1. 2、服务器链接失败重新连,第一个人排到队尾,概率为p2. 3、连接成功,第一个人出队,概率为p3. 4、服务器崩塌,终止,概率为p4. 求某人排在第m的位置,求服务器崩塌时他前面

cc_again的专栏 2170

华为的C语言编程规范.pdf

华为技术有限公司内部技术规范。本规范制定了编写C语言程序的基本原则、规则和建议。从代码的清晰、简洁、可测试、安全、程序效率、可移植各个方面对C语言编程作出了具体指导。

精雕软件(JDpaint) 5.5 绿色版

精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版

HDU 4089 Activation [有环的概率DP]

After 4 years' waiting, the game "Chinese Paladin 5" finally comes out. —— 现在一队人在排队等待进入游戏,但是服务器每一个时刻有概率发生下面4种事件: P1的概率发生 队首的人进入游戏失败,下一时刻继续进入(相等于什么都不发生; P2的概率发生 队首的人掉线,但是他会马上重连,并进入队尾; P3的概率发生 队首的人成功连入游戏,这个人会从队伍中消失; P4的概率发生 服务器挂掉..... 现在Tomato正在排的队伍有N个人,他现在

Asuna_acmer 560

Probability and Statistics - 4th edition

Probability and Statistics - 4th edition

[HDU 4089]Activation[概率DP]

概率DP. 找不到思路的主要原因是不清楚dp数组到底用来表示什么. 进而无法合适地分析状态转移. 概率DP是将从当前状态到最终状态一系列多重的选择"封装", 表示为一个最终结果, 然后根据题意的转移方式, 严格分离等号左右两边(常有自我循环, 若是不刻意分别对待容易混乱). 式子列好之后再考虑怎么解.

以中有足乐者... 1765

假人有限元模型

假人模型,车辆碰撞假人有限元模型,适合做乘员安全的研究者利用

hdu4089Activation 概率dp

//一条队列对于第一个人的情况 //概率p1:队列保持不变 //p2:第一个人到队尾 //p3:第一个人出队 //p4:系统崩溃 //队列中有N个人,Tomato 在第M位置,求系统崩溃,Tomato 前面的人数为小于k个人的情况的概率 //dp[i][j] 表示队列中有i个人,Tomato 在第j个位置时出现目标状态的概率 //可以很容易得到递推公式 //dp[i][1] = p

ijbuhv的专栏 1628

HDU 4089 Activation(概率DP)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4089 题意:n个人排成一队,小白排在第m个。对于队头的人,有四种可能: (1)概率p1,保持不动; (2)概率p2,换到队尾,第二个人成为队头; (3)概率p3,走了,再也不回来了,第二个人成为队头; (4)概率p4,游戏结束。 求结束时小白的排名小于等于K的概率。 思路:设dp[i][...

weixin_33819479的博客 124

HDU 4089 Activation 概率dp

Activation Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1874    Accepted Submission(s): 695 Problem Description After 4 years' wai

Aosaki 460

HDU4089 Activation 概率DP

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4089 Activation Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 2382    Accepted Subm

AC_Gibson的专栏 642

【概率DP】 HDU 4089 Activation

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

164

HDU4089 Activation【概率DP】

Time Limit: 20000/10000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others) Problem Description After 4 years' waiting, the game "Chinese Paladin 5" finally comes out. Tomato is a crazy f...

MaJorieL 197

概率dp HDU 4089 Activation

ActivationTime Limit: 20000/10000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1142    Accepted Submission(s): 412Problem DescriptionAfter 4 years' waiting, the ga

We Can 573

Hdu 4089 Activation 概率DP

Activation Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 4239    Accepted Submission(s): 1418 Problem Description After 4 years

J. Cole 328

HDU 4089 Activation(概率dp)

Activation Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 4222    Accepted Submission(s): 1411 Problem Description After 4 years' waiting...

alpc_qleonardo 513

HDU4089:Activation(概率DP)

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

anquan1533的博客 157
上一篇: ZOJ3329-One Person Game(概率DP求数学期望)
下一篇: HDU2149-Good Luck in CET-4 Everybody!(博弈,打表找规律)
mowayao
博客等级 码龄15年 18粉丝 217原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值