freeCodeCamp/curriculum/challenges/chinese/10-coding-interview-prep/project-euler/problem-219-skew-cost-codin...

30 lines
899 B
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: 5900f4481000cf542c50ff5a
title: 问题219偏差成本编码
challengeType: 5
videoUrl: ''
---
# --description--
设A和B为位串0和1的序列。如果A等于B的最左边长度A则A被称为B的前缀。例如00110是001101001的前缀但不是00111或100110的前缀。
大小为n的无前缀代码是n个不同位串的集合因此没有字符串是任何其他字符串的前缀。例如这是一个大小为6的无前缀代码
0000,0001,001,01,10,11
现在假设发送'0'位需要一分钱,而传输'1'需要4便士。然后上面显示的无前缀代码的总成本是35便士这恰好是所讨论的偏斜定价方案可能最便宜的。简而言之我们写Cost6= 35。
什么是成本109
# --hints--
`euler219()`应返回64564225042。
```js
assert.strictEqual(euler219(), 64564225042);
```
# --solutions--