freeCodeCamp/curriculum/challenges/chinese/10-coding-interview-prep/project-euler/problem-436-unfair-wager.md

72 lines
1.7 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

---
id: 5900f5221000cf542c510033
challengeType: 5
videoUrl: ''
localeTitle: 问题436不公平的赌注
---
## Description
<section id="description">
朱莉向妹妹路易丝提出以下赌注。
她建议他们玩一场机会游戏,以确定谁来洗碗。
对于此游戏他们应使用独立随机数的生成器该生成器均匀分布在0和1之间。
游戏从S = 0开始。
第一个玩家路易丝Louise向生成器添加了S个不同的随机数直到S> 1并记录了她的最后一个随机数'x'。
第二个玩家朱莉继续从生成器中添加S个不同的随机数直到S> 2并记录她的最后一个随机数“ y”。
拥有最高数字的玩家获胜而输家则洗碗如果y> x则第二名玩家获胜。
例如如果第一个玩家抽出0.62和0.44则第一个玩家回合结束因为0.62 + 0.44> 1且x = 0.44。
如果第二名玩家抽出0.1、0.27和0.91则第二名玩家回合结束因为0.62 + 0.44 + 0.1 + 0.27 + 0.91> 2且y = 0.91。
由于y> x第二名玩家获胜。
路易丝考虑了一秒钟,然后反对:“那不公平”。
第二名玩家获胜的概率是多少?
以0.abcdefghij的形式将答案四舍五入到小数点后10位。
</section>
## Instructions
<section id="instructions">
</section>
## Tests
<section id='tests'>
```yml
tests:
- text: <code>euler436()</code>应该返回0.5276662759。
testString: assert.strictEqual(euler436(), 0.5276662759);
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
function euler436() {
// Good luck!
return true;
}
euler436();
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
/section>