我的做法就是暴力,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. sending data mysql slow Mysql查询非常慢的可能原因

    1.用explain看看mysql的执行情况,可以得知,task_id扫描了近20万条数据,而且这个task_id不是索引 2.为这个task_id所在的表,将此字段添加索引后,查询就变得很快了

  2. 助力深度学习!阿里开源可插拔 GPU 共享调度工具

    根据 Gartner 对全球 CIO 的调查结果显示,人工智能将成为 2019 年组织革命的颠覆性力量.对于人工智能来说,算力即正义,成本即能力,利用 Docker 和 Kubernetes 代表云原 ...

  3. Django与HTML业务基本结合

    app里都有migrations文件 app: migrations 数据修改表结构,数据库操作记录 admin Django为我们提供后台管理 apps 配置当前app models ORM,写指定 ...

  4. 架构 - 业务流程管理介绍(BPM)

    什么是业务流程 维基百科中说,业务流程是为特定的对象(客户)创造价值的过程,这一过程由一系列相关联.有组织的活动或任务组成.企业和组织中的流程常常划分为三种基本类型: 管理流程——对系统运作进行管制. ...

  5. 转: CentOS上安装LAMP之第二步:PHP环境及安装过程报错解决方案(纯净系统环境)

    最近有空就配置CentOS系统上的AMP环境,现在配置到PHP环境了 多话不说上传送门:http://blog.csdn.net/zhangatle/article/details/77447653 ...

  6. phpstorm服务器配置

    转载自百度经验https://jingyan.baidu.com/article/84b4f565ea229960f6da320c.html 这个教程里面后面修改的两步目前没有用到,之后可能会用到,暂 ...

  7. 第八章—BOM(一)

    ECMAscript是JS的核心,而要在web上使用JS,那么BOM无疑是真正的核心.BOM叫浏览器对象模型,它提供了许多对象,用于访问浏览器的功能. BOM的核心对象是window,它表示浏览器的一 ...

  8. 简单介绍几个CSSReset的方法

    对于小型的网站来说,用这个并不会带来大的资源浪费,但如果是像Yahoo这种架构非常大的网站,必须要有选择地进行CSS重设,以减 少资源浪费. 正在使用CSS的你,用过CSS Reset吗?当然,或许你 ...

  9. less知识点总结(一)

    1.unit 删除或更换单位. 参数: dimension: 带单位或不带单位的数字. unit: (可选) 目标单位,如果省略此参数,则删除单位. See convert for changing ...

  10. iOS 停止不必要的UI动效设计

    http://www.cocoachina.com/design/20151124/14400.html 前言:这篇短文将会探讨UI设计中动画的过度使用,并将其与早期的视觉设计进行对比,提出一些对于有 ...