freeCodeCamp/curriculum/challenges/chinese/10-coding-interview-prep/project-euler/problem-150-searching-a-triangular-array-for-a-sub-triangle-having-minimum-sum.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

1.5 KiB
Raw Blame History

id, title, challengeType, videoUrl, dashedName
id title challengeType videoUrl dashedName
5900f4031000cf542c50ff15 问题150在三角形阵列中搜索具有最小和的子三角形 5 problem-150-searching-a-triangular-array-for-a-sub-triangle-having-minimum-sum

--description--

在正整数和负整数的三角形阵列中,我们希望找到一个子三角形,使得它包含的数字之和尽可能小。在下面的示例中,可以很容易地验证标记的三角形满足具有-42的总和的条件。

我们希望制作一个包含一千行的三角形数组因此我们使用一种随机数生成器称为线性同余生成器生成5009个伪随机数sk范围为±219如下所示t= 0

对于k = 1到k = 500500

t=615949 * t + 797807modulo 220 sk= t-219因此s1 = 273519s2 = -153582s3 = 450905等我们的三角形数组然后使用伪随机数形成

s1 s2 s3 s4 s5 s6

s7 s8 s9 s10 ......

子三角形可以从数组的任何元素开始,并在我们喜欢的范围内向下延伸(从下一行直接接收它下面的两个元素,之后直接从该行下面的三个元素,依此类推)。

“三角形的总和”定义为它包含的所有元素的总和。

找到可能的最小子三角形和。

--hints--

euler150()应返回-271248680。

assert.strictEqual(euler150(), -271248680);

--seed--

--seed-contents--

function euler150() {

  return true;
}

euler150();

--solutions--

// solution required