我的做法就是暴力,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. Ajax--serialize应用表单数据序列化

    一.jQuery+Ajax表单数据序列化 <!DOCTYPE html> <html> <head> <meta charset="UTF-8&qu ...

  2. 通过sql 向数据库插入多行语句

    我们知道通过insert into 表名(列名) values(值)是向表中插入一条语句,可是当我们需要向数据库插入多条语句时,应该怎么做呢? 可以通过如下格式的sql 语句来实现一次向数据库插入多行 ...

  3. 导入pymysql模块出错:No module named 'pymysql'

    前提: 使用的版本为:Python 3.6.4 pymysql已经被成功安装了,并通过命令行的方式验证已成功安装. 但在pycharm中运行工程时候时候报错:No module named 'pymy ...

  4. 问题解决:listview多次调用addHeaderView和addFooterView

    情景: 有两个分类,每个分类下的数据用listview显示,分类1需要显示头视图和尾视图,分类2不要显示头视图和尾视图 .两个分类可以来回切换. 实现的步骤: 1. addHeaderView . a ...

  5. NFS服务器搭建与配置

    原文:https://blog.csdn.net/qq_38265137/article/details/83146421 NFS服务简介什么是NFS?NFS就是Network File System ...

  6. ubuntu上安装notepadpp

    Notepad++是一套非常有特色的自由软件的纯文字编辑器(许可证:GPL).有完整的中文化接口及支持多国语言编写的功能(UTF8 技术).它的功能比 Windows 中的 Notepad(记事本)强 ...

  7. 【机器学习PAI实战】—— 玩转人工智能之利用GAN自动生成二次元头像

    前言 深度学习作为人工智能的重要手段,迎来了爆发,在NLP.CV.物联网.无人机等多个领域都发挥了非常重要的作用.最近几年,各种深度学习算法层出不穷, Generative Adverarial Ne ...

  8. Directx11教程41 纹理映射(11)

    原文:Directx11教程41 纹理映射(11)     1.第一副图我们采用各性异性的滤波方式,并设置最大各性异性值为8.     samplerDesc.Filter =  D3D11_FILT ...

  9. 支付宝sdk iOS 集成

    1添加支付宝源文件和库文件AlipayOrder.h    AlipayOrder.m    AlipayResult.h    AlipayResult.m  AlixLibService.h   ...

  10. C++模板进阶指南:SFINAE

    C++模板进阶指南:SFINAE 空明流转(https://zhuanlan.zhihu.com/p/21314708) SFINAE可以说是C++模板进阶的门槛之一,如果选择一个论题来测试对C++模 ...