HBC50882翻转直角三角形图案Eddy Walker题解

别敷衍了所有 算法基础篇 50 0
题库丰富多样,涵盖各个领域,全网最全C++题库,让您在练习中不断成长!
Eddy likes to walk around. Especially, he likes to walk in a loop called "Infinite loop". But, actually, it's just a loop with finite length. Eddy can walk in a fixed length. He finds that it takes him N steps to walk through the loop a cycle. Then, he puts N marks on the "Infinite loop" labeled with 0,1,…

Eddy likes to walk around. Especially, he likes to walk in a loop called "Infinite loop". But, actually, it's just a loop with finite length(Anyway, the name doesn't matter). Eddy can walk in a fixed length. He finds that it takes him N steps to walk through the loop a cycle. Then, he puts N marks on the "Infinite loop" labeled with 0,1,…,N−10, 1, ldots, N-10,1,…,N−1, where i and i+1 are a step away each other, so as 0 and N-1. After that, Eddy stands on the mark labeled 0 and start walking around. For each step, Eddy will independently uniformly randomly choose to move forward or backward. If currently Eddy is on the mark labeled i, he will on the mark labeled i+1 if move forward or i-1 if move backward. If Eddy is on the mark labeled N-1 and moves forward, he will stand on the mark labeled 0. If Eddy is on the mark labeled 0 and moves backward, he will stand on the mark labeled N-1. Although, Eddy likes to walk around. He will get bored after he reaches each mark at least once. After that, Eddy will pick up all the marks, go back to work and stop walking around. You, somehow, notice the weird convention Eddy is doing. And, you record T scenarios that Eddy walks around. For i-th scenario, you record two numbers NiN_iNi​, MiM_iMi​, where NiN_iNi​ tells that in the i-th scenario, Eddy can walk through the loop a cycle in exactly NiN_iNi​ steps(Yes! Eddy can walk in different fixed length for different day.). While MiM_iMi​ tells that you found that in the i-th scenario, after Eddy stands on the mark labeled MiM_iMi​, he reached all the marks. However, when you review your records, you are not sure whether the data is correct or even possible. Thus, you want to know the probability that those scenarios will happen. Precisely, you are going to compute the probability that first i scenarios will happen sequentially for each i.textbf{Precisely, you are going to compute the probability that first i scenarios will happen sequentially for each i.}Precisely, you are going to compute the probability that first i scenarios will happen sequentially for each i.

HBC50882翻转直角三角形图案Eddy Walker题解
-第1张图片-东莞河马信息技术
(图片来源网络,侵删)
想要在职场中立于不败之地?那就来试试全网最全C++题库,让您在练习中快速提升技能。

标签: HBC50882翻转直角三角形图案Eddy Walker题解