2018-10-10 22:03:03 +00:00
|
|
|
|
---
|
|
|
|
|
id: 5900f4971000cf542c50ffa9
|
|
|
|
|
challengeType: 5
|
|
|
|
|
videoUrl: ''
|
2020-10-01 15:54:21 +00:00
|
|
|
|
title: 问题298:选择性健忘症
|
2018-10-10 22:03:03 +00:00
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
## Description
|
2020-02-17 16:40:55 +00:00
|
|
|
|
<section id="description">
|
|
|
|
|
拉里(Larry)和罗宾(Robin)玩着一场记忆游戏,其中涉及一个随机数序列,介于1到10之间(含1和10),每次被召唤一个。每个玩家最多可以记住5个先前的数字。当被叫号码在玩家的记忆中时,该玩家将获得积分。如果不是,则播放器将被叫号码添加到他的记忆中,如果他的记忆已满,则删除另一个号码。
|
|
|
|
|
|
|
|
|
|
两位选手都以空洞的回忆开始。两位玩家总是向他们的记忆中添加新的遗漏号码,但是在决定删除哪个号码时使用不同的策略:
|
|
|
|
|
拉里(Larry)的策略是删除最长时间内未拨打的电话。
|
|
|
|
|
Robin的策略是删除内存中时间最长的数字。
|
|
|
|
|
|
|
|
|
|
范例游戏:Turn
|
|
|
|
|
被叫号码
|
|
|
|
|
拉里的记忆
|
|
|
|
|
拉里的比分
|
|
|
|
|
罗宾的记忆
|
|
|
|
|
罗宾的分数
|
|
|
|
|
1个
|
|
|
|
|
1个
|
|
|
|
|
1个
|
|
|
|
|
0
|
|
|
|
|
1个
|
|
|
|
|
0
|
|
|
|
|
2
|
|
|
|
|
2
|
|
|
|
|
1,2
|
|
|
|
|
0
|
|
|
|
|
1,2
|
|
|
|
|
0
|
|
|
|
|
3
|
|
|
|
|
4
|
|
|
|
|
1,2,4
|
|
|
|
|
0
|
|
|
|
|
1,2,4
|
|
|
|
|
0
|
|
|
|
|
4
|
|
|
|
|
6
|
|
|
|
|
1,2,4,6
|
|
|
|
|
0
|
|
|
|
|
1,2,4,6
|
|
|
|
|
0
|
|
|
|
|
5
|
|
|
|
|
1个
|
|
|
|
|
1,2,4,6
|
|
|
|
|
1个
|
|
|
|
|
1,2,4,6
|
|
|
|
|
1个
|
|
|
|
|
6
|
|
|
|
|
8
|
|
|
|
|
1,2,4,6,8
|
|
|
|
|
1个
|
|
|
|
|
1,2,4,6,8
|
|
|
|
|
1个
|
|
|
|
|
7
|
|
|
|
|
10
|
|
|
|
|
1,4,6,8,10
|
|
|
|
|
1个
|
|
|
|
|
2,4,6,8,10
|
|
|
|
|
1个
|
|
|
|
|
8
|
|
|
|
|
2
|
|
|
|
|
1,2,6,8,10
|
|
|
|
|
1个
|
|
|
|
|
2,4,6,8,10
|
|
|
|
|
2
|
|
|
|
|
9
|
|
|
|
|
4
|
|
|
|
|
1,2,4,8,10
|
|
|
|
|
1个
|
|
|
|
|
2,4,6,8,10
|
|
|
|
|
3
|
|
|
|
|
10
|
|
|
|
|
1个
|
|
|
|
|
1,2,4,8,10
|
|
|
|
|
2
|
|
|
|
|
1,4,6,8,10
|
|
|
|
|
3
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
用L表示拉里的分数,用R表示罗宾的分数,| L-R |的期望值是多少? 50转后?使用x.xxxxxxxx格式将答案四舍五入到小数点后八位。
|
|
|
|
|
</section>
|
2018-10-10 22:03:03 +00:00
|
|
|
|
|
|
|
|
|
## Instructions
|
2020-02-17 16:40:55 +00:00
|
|
|
|
<section id="instructions">
|
|
|
|
|
</section>
|
2018-10-10 22:03:03 +00:00
|
|
|
|
|
|
|
|
|
## Tests
|
|
|
|
|
<section id='tests'>
|
|
|
|
|
|
|
|
|
|
```yml
|
|
|
|
|
tests:
|
2020-02-17 16:40:55 +00:00
|
|
|
|
- text: <code>euler298()</code>应该返回1.76882294。
|
|
|
|
|
testString: assert.strictEqual(euler298(), 1.76882294);
|
2018-10-10 22:03:03 +00:00
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
## Challenge Seed
|
|
|
|
|
<section id='challengeSeed'>
|
|
|
|
|
|
|
|
|
|
<div id='js-seed'>
|
|
|
|
|
|
|
|
|
|
```js
|
|
|
|
|
function euler298() {
|
|
|
|
|
// Good luck!
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
euler298();
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
## Solution
|
|
|
|
|
<section id='solution'>
|
|
|
|
|
|
|
|
|
|
```js
|
|
|
|
|
// solution required
|
|
|
|
|
```
|
2020-08-13 15:24:35 +00:00
|
|
|
|
|
|
|
|
|
/section>
|