freeCodeCamp/curriculum/challenges/chinese/10-coding-interview-prep/project-euler/problem-278-linear-combinat...

841 B
Raw Blame History

id title challengeType videoUrl
5900f4831000cf542c50ff95 问题278半正定的线性组合 5

--description--

给定整数1 <a1 <a2 <... <an的值考虑线性组合q1a1 + q2a2 + ... + qnan = b仅使用整数值qk≥0。

注意对于给定的ak集合可能不是b的所有值都是可能的。例如如果a1 = 5且a2 = 7则没有q1≥0且q2≥0使得b可以是1,2,3,4,6,8,9,11,13,16,18或23 。

事实上23是a1 = 5和a2 = 7的b的最大不可能值。因此我们称f5,7= 23.同样可以证明f6,10,15= 29和f14,22,77= 195。

找到Σfp qp rq * r其中pq和r是素数p <q <r <5000。

--hints--

euler278()应该返回1228215747273908500。

assert.strictEqual(euler278(), 1228215747273908500);

--solutions--