![](https://img-blog.csdnimg.cn/20201014180756922.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
欧拉计划
西洋樱草x
这个作者很懒,什么都没留下…
展开
-
欧拉计划 第15题 Lattice paths
题目 从2×2格子的左上角开始移动,只能向右或者向下移动,到达右下角共有6条路径。 在20×20的格子中,有多少条这样的路径? 思路 我们利用2×2的格子中的3×3个顶点来计算到达每个顶点有多少条路径,我们初始化一个数组3×3的数组x,其中每个值为0,之后会对其进行更新。 对于最上边一行和最左边一行的顶点来说,从起点开始向右或向下到达这些顶点的路径只有一条,所以我们将x[0][0],x[0][1],x[0][2],x[1][0]和x[2][0]都更新为1。 到达第二行的第二个顶点的路径数=(到达原创 2020-09-19 10:09:17 · 217 阅读 · 0 评论 -
欧拉计划 第18题 Maximum path sum I
问题 从最顶端的数字开始,向下一行的邻接数字移动,求:从顶端到底端的最大总数是多少? 思路 我们从下往上计算,从倒数第二行开始,将每个数字更新为(下一行与其邻接的两个数字中的最大值+数字本身),即倒数第二行的63更新为125(计算过程为max(04,62)+63),这样更新的每一个数字都是从该数字向下移动得到最大的总和,最终,最顶端更新后的数字即为该题所求答案。 代码实现(python) x = '''75 95 64 17 47 82 18 35 87 10 20 04 82 47 6..原创 2020-09-18 15:59:02 · 226 阅读 · 0 评论 -
欧拉计划 第12题 Highly divisible triangular number
题目 The sequence of triangle numbers is generated by adding the natural numbers. So the 7thtriangle number would be 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28. The first ten terms would be: 1, 3, 6, 10, 15, 21, 28, 36, 45, 55, ... Let us list the factors of the fir.原创 2020-09-17 09:25:33 · 129 阅读 · 0 评论 -
欧拉计划 第4题 Largest palindrome product
题目 A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99. Find the largest palindrome made from the product of two 3-digit numbers. 回文数两个方向读的是一样的。两个两位数相乘得到的最大的回文数是9009 = 91 ×原创 2020-09-16 22:36:36 · 152 阅读 · 0 评论 -
欧拉计划 第3题 Largest prime factor
题目 The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 600851475143 ? 13195的素因数是5,7,13,29,问:600851475143的最大素因数是多少? 思路 求解素因数,即找到一个只能被1和它本身整除的因数。n = a * b,a 和 b 是 n 的两个因数,假设 a ≤ b,那么 a ≤ 根号 n,b ≥ 根号n,我们只需要判断n能否原创 2020-09-16 21:18:27 · 217 阅读 · 0 评论 -
欧拉计划 第5题 Smallest multiple
问题 2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder. What is the smallest positive number that isevenly divisibleby all of the numbers from 1 to 20? 2520可以被1-10的每一个数整除,能被1-20每个数整除的最小的正数是多少? 思路 ..原创 2020-09-16 20:54:01 · 211 阅读 · 0 评论