我的做法就是暴力,1+...+n 用前n项和公式就行

12+22+....+n^2就暴力了

做完后在讨论版发现两个有趣的东西。

一个是 (1+2+3+...+n)2=(13)+(23)+(33)+...+(n^3)

另一个是 12+22+....+n^2的公式以及推导。

假设f(n) = an3 + bn2 + cn + d

已知:f(0) = 0; f(1) = 1; f(2) = 5; f(3) = 14

然后带入解方程,得到a,b,c,d,再用归纳法证明其正确性。

证明过程在给出的题解中。

公式:1^2 + 2^2 + ... + n^2 = n * (n+1) * (2n+1) * 1/6

天知道他是怎么想到把方程假设成那样的。不过百度搜搜也有推导。

a = 5050*5050
b = 0
for x in range(1,100+1):
b += x*x
print a-b

Porject Euler Problem 6-Sum square difference的更多相关文章

  1. Problem 6: Sum square difference

    The sum of the squares of the first ten natural numbers is, 12 + 22 + ... + 102 = 385 The square of ...

  2. (Problem 6)Sum square difference

    Hence the difference between the sum of the squares of the first ten natural numbers and the square ...

  3. Sum square difference

    简单: e sum of the squares of the first ten natural numbers is, 12 + 22 + ... + 102 = 385 The square o ...

  4. projecteuler Sum square difference

    The sum of the squares of the first ten natural numbers is, 12 + 22 + ... + 102 = 385 The square of ...

  5. Project Euler 44: Find the smallest pair of pentagonal numbers whose sum and difference is pentagonal.

    In Problem 42 we dealt with triangular problems, in Problem 44 of Project Euler we deal with pentago ...

  6. (Problem 57)Square root convergents

    It is possible to show that the square root of two can be expressed as an infinite continued fractio ...

  7. Project Euler Problem 18-Maximum path sum I & 67-Maximum path sum II

    基础的动态规划...数塔取数问题. 状态转移方程: dp[i][j] = num[i][j] + max(dp[i+1][j],dp[i+1][j+1]);

  8. Project Euler Problem 16-Power digit sum

    直接python搞过.没啥好办法.看了下别人做的,多数也是大数乘法搞过. 如果用大数做的话,c++写的话,fft优化大数乘法,然后快速幂一下就好了.

  9. Project Euler Problem 10

    Summation of primes Problem 10 The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17. Find the sum of ...

随机推荐

  1. 【CodeVS】2822 爱在心中 [2017年6月计划 强连通分量03]

    2822 爱在心中 时间限制: 1 s 空间限制: 128000 KB 题目等级 : 钻石 Diamond         题目描述 Description “每个人都拥有一个梦,即使彼此不相同,能够 ...

  2. bzoj 1191 [HNOI2006]超级英雄Hero——二分图匹配

    题目:https://www.lydsy.com/JudgeOnline/problem.php?id=1191 不就是个最大匹配么. 结果WA得不行. 看TJ后发现题面上说了一旦没回答出一道题就结束 ...

  3. python 中初始化二维数组的方法

    最好的方法是: 初始化4*3的二维数组 a = [[0 for col in xrange(3)] for row in xrange(4)] 而不可以用: a = [[0]*3]*4 [0]*3是生 ...

  4. SEO优化步骤

    SEO技术并不是简单的几个建议,而是一项需要足够耐心和细致的脑力劳动.大体上,SEO优化主要分为8小步: 1.关键词分析(也叫关键词定位) 这是进行SEO优化最重要的一环,关键词分析包括:关键词关注量 ...

  5. Python之路--协程/IO多路复用

    引子: 之前学习过了,线程,进程的概念,知道了在操作系统中进程是资源分配的最小单位,线程是CPU调度的最小单位.按道理来说我们已经算是把CPU的利用率提高很多了.但是我们知道无论是创建多进程还是创建多 ...

  6. 2018-5-4-WPF-获得触摸精度和触摸点

    title author date CreateTime categories WPF 获得触摸精度和触摸点 lindexi 2018-05-04 21:11:51 +0800 2018-5-4 21 ...

  7. PHPCMS快速建站系列之getcache()的用法

    /** * 读取缓存,默认为文件缓存,不加载缓存配置. * @param string $name 缓存名称 * @param $filepath 数据路径(模块名称) caches/cache_$f ...

  8. layui的select联动 - CSDN博客

    要实现联动效果注意两点: 第一要可以监听到select的change事件: 第二异步加载的内容,需要重新渲染后才可以 正常使用. html结构: <form class="layui- ...

  9. python流程控制和循环

    变量的命名:可以由数字字母下换线组成 ,不能以数字开头,可以使用中文但是不推荐使用中文,不推荐前面使用_ __,不能使用系统的关键字,变量名严格区分大小写 逻辑运算优先级 or<and<n ...

  10. Linux配置redis开机启动(CentOS 7)

    https://blog.csdn.net/qq_31803503/article/details/79246205 本次配置linux版本是CentOS 7 首先将  redis-3.2.3/uti ...