我的做法就是暴力,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. SQL Sever实验三 视图与数据更新

    一. 实验目的 1.掌握创建视图的 SQL 语句,数据更新的 SQL 语句. 2.了解使用创建视图向导创建视图的方法. 3.掌握使用 SQL 创建视图的方法,使用 SQL 更新数据的方法. 二. 实验 ...

  2. 微信小程序--每个独立的page的page.json只能修改window属性

    app.json 配置项列表 app.json文件用来对微信小程序进行全局配置,决定页面文件的路径.窗口表现.设置网络超时时间.设置多 tab 等. window配置 用于设置小程序的状态栏.导航条. ...

  3. Hdu 2389 二分匹配

    题目链接 Rain on your Parade Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 655350/165535 K (Ja ...

  4. laravel-admin

    laravel-admin 文档地址: http://laravel-admin.org/docs/#/zh/

  5. 软工作业———Alpha版本第二周小结

    姓名 学号 周前计划安排 每周实际工作记录 自我打分 zxl 061425 1.进行任务分配2.实现扫码和生成二维码功能 1.对主要任务进行了划分,但还为进行给模块间的联系2.完成了扫码签到功能 90 ...

  6. nginx配置静态资源压缩

    sendfile on; #让nginx在传输文件时直接在磁盘和tcp socket之间传输数据 location ~ .*\.(txt|xml)$ { gzip on; #开启压缩 gzip_htt ...

  7. 洛谷 P4205 [NOI2005]智慧珠游戏 DFS

    目录 题面 题目链接 题目描述 输入输出格式 输入格式 输出格式 输入输出样例 输入样例 输出样例 说明 思路 AC代码 总结 题面 题目链接 P4205 [NOI2005]智慧珠游戏 题目描述 智慧 ...

  8. 【水滴石穿】rnTest

    其实就是一个小的demo,不过代码分的挺精巧的 先放地址:https://github.com/linchengzzz/rnTest 来看看效果 确实没有什么可以说的,不过代码部分还行 先入口文件 / ...

  9. QT加载qss

    QString CommonHelper::setStyle(const QString &style) { QByteArray str; QFile qss(style); qss.ope ...

  10. JavaScript--取消a标签和form的submit提交默认行为

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...