Files
freeCodeCamp/curriculum/challenges/chinese/10-coding-interview-prep/project-euler/problem-406-guessing-game.md
Oliver Eyton-Williams ee1e8abd87 feat(curriculum): restore seed + solution to Chinese (#40683)
* feat(tools): add seed/solution restore script

* chore(curriculum): remove empty sections' markers

* chore(curriculum): add seed + solution to Chinese

* chore: remove old formatter

* fix: update getChallenges

parse translated challenges separately, without reference to the source

* chore(curriculum): add dashedName to English

* chore(curriculum): add dashedName to Chinese

* refactor: remove unused challenge property 'name'

* fix: relax dashedName requirement

* fix: stray tag

Remove stray `pre` tag from challenge file.

Signed-off-by: nhcarrigan <nhcarrigan@gmail.com>

Co-authored-by: nhcarrigan <nhcarrigan@gmail.com>
2021-01-12 19:31:00 -07:00

49 lines
2.0 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
id: 5900f5021000cf542c510015
title: 问题406猜猜游戏
challengeType: 5
videoUrl: ''
dashedName: problem-406-guessing-game
---
# --description--
我们试图通过提问来找到从整数集{1,2...n}中选择的隐藏数字。我们问的每个数字问题我们得到三个可能的答案之一“你的猜测低于隐藏的数字”并且你需要花费一个成本或者“你的猜测高于隐藏的数字”和你承担b的费用或“是的就是这样游戏结束。给定na和b的值最优策略最小化最坏情况下的总成本。
例如如果n = 5a = 2b = 3那么我们可以先问“2”作为我们的第一个问题。
如果我们被告知2高于隐藏号码b = 3的成本那么我们确定“1”是隐藏号码总成本为3。如果我们被告知2低于隐藏号码a = 2的成本那么我们的下一个问题将是“4”。如果我们被告知4高于隐藏号码b = 3的成本那么我们确定“3”是隐藏号码总成本为2 + 3 = 5。如果我们被告知4低于隐藏号码a = 2的成本那么我们确定“5”是隐藏号码总成本为2 + 2 = 4。因此该策略实现的最坏情况成本为5.还可以证明这是可以实现的最低的最坏情况成本。所以事实上我们刚刚描述了给定na和b值的最优策略。
设Cnab是针对给定na和b值的最优策略实现的最坏情况成本。
以下是几个例子C5,2,3= 5 C500√2√3= 13.22073197 ... C20000,5,7= 82 C2000000√5√7 = 49.63755955 ......
设Fk为斐波纳契数Fk = Fk-1 + Fk-2基本情况F1 = F2 =1.FindΣ1≤k≤30C1012√k√Fk并将答案四舍五入为8小数点后面的小数位数。
# --hints--
`euler406()`应返回36813.12757207。
```js
assert.strictEqual(euler406(), 36813.12757207);
```
# --seed--
## --seed-contents--
```js
function euler406() {
return true;
}
euler406();
```
# --solutions--
```js
// solution required
```