本题来自 Project Euler 第6题:https://projecteuler.net/problem=6

# Project Euler: Problem 6: Sum square difference
# The sum of the squares of the first ten natural numbers is,
# 1**2 + 2**2 + ... + 10**2 = 385
# The square of the sum of the first ten natural numbers is,
# (1 + 2 + ... + 10)**2 = 552 = 3025
# Hence the difference between the sum of the squares of the first ten natural numbers
# and the square of the sum is 3025 − 385 = 2640.
# Find the difference between the sum of the squares
# of the first one hundred natural numbers and the square of the sum.
# Answer: 25164150 x = y = 0
for i in range(1, 101):
x += i
y += i**2
print(x**2 - y)

这题纯粹是送分题,就是简单的加减法和乘方计算。应该没啥算法可言吧。。。

Python练习题 034:Project Euler 006:和平方与平方和之差的更多相关文章

  1. Python练习题 032:Project Euler 004:最大的回文积

    本题来自 Project Euler 第4题:https://projecteuler.net/problem=4 # Project Euler: Problem 4: Largest palind ...

  2. Python练习题 029:Project Euler 001:3和5的倍数

    开始做 Project Euler 的练习题.网站上总共有565题,真是个大题库啊! # Project Euler, Problem 1: Multiples of 3 and 5 # If we ...

  3. Python练习题 046:Project Euler 019:每月1日是星期天

    本题来自 Project Euler 第19题:https://projecteuler.net/problem=19 ''' How many Sundays fell on the first o ...

  4. Python练习题 039:Project Euler 011:网格中4个数字的最大乘积

    本题来自 Project Euler 第11题:https://projecteuler.net/problem=11 # Project Euler: Problem 10: Largest pro ...

  5. Python练习题 033:Project Euler 005:最小公倍数

    本题来自 Project Euler 第5题:https://projecteuler.net/problem=5 # Project Euler: Problem 5: Smallest multi ...

  6. Python练习题 049:Project Euler 022:姓名分值

    本题来自 Project Euler 第22题:https://projecteuler.net/problem=22 ''' Project Euler: Problem 22: Names sco ...

  7. Python练习题 048:Project Euler 021:10000以内所有亲和数之和

    本题来自 Project Euler 第21题:https://projecteuler.net/problem=21 ''' Project Euler: Problem 21: Amicable ...

  8. Python练习题 047:Project Euler 020:阶乘结果各数字之和

    本题来自 Project Euler 第20题:https://projecteuler.net/problem=20 ''' Project Euler: Problem 20: Factorial ...

  9. Python练习题 045:Project Euler 017:数字英文表达的字符数累加

    本题来自 Project Euler 第17题:https://projecteuler.net/problem=17 ''' Project Euler 17: Number letter coun ...

随机推荐

  1. 数字电路基础(三)TTL与非门输入端接电压表的示数

    如下图所示,当ui输入低电平,电压表示数为0.3v,当ui输入高电平时,电压表示数为1.4v,分析如下 当ui=0.3 此时VT1导通,电流都从输入端流出,VT1的基极电位被钳位在1.0v(Ub1=0 ...

  2. 2020年的UWP——通过Radio类控制Cellular(1)

    最近在做UWP的项目,在2020年相信这已经是相对小众的技术了,但是在学习的过程中,发现某软这么几年仍然添加了不少的API,开放了相当多的权限.所以打算总结一下最近的一些经验和收获,介绍一下2020年 ...

  3. boot 项目启动报Cannot datermine embedded database driver class for database type NONE

    部署boot项目时报Cannot datermine embedded database driver class for database type NONE数据库链接什么的也都没有问题,经过百度 ...

  4. HashSet保证元素唯一原理以及HashMap扩容机制

    一.HashSet保证元素唯一原理: 依赖于hashCode()和equals()方法1.唯一原理: 1.1 当HashSet集合要存储元素的时候,会调用该元素的hashCode()方法计算哈希值 1 ...

  5. 第一次编程作业(My Own Score)

    博客班级 https://edu.cnblogs.com/campus/fzzcxy/2018SE2 作业要求 https://edu.cnblogs.com/campus/fzzcxy/2018SE ...

  6. pytorch常用函数总结(持续更新)

    pytorch常用函数总结(持续更新) torch.max(input,dim) 求取指定维度上的最大值,,返回输入张量给定维度上每行的最大值,并同时返回每个最大值的位置索引.比如: demo.sha ...

  7. IT行业程序开发如何

    学习程序开发怎么样,由于软件开发涉及到的知识结构比较丰富,所以学习软件开发通常需要一个系统的学习过程.如果未来要想专业从事软件开发工作,那么可以按照以下步骤学习软件开发技术: 第一:从计算机操作系统开 ...

  8. jmeter中接口测试出现乱码或不识别中文解决办法

    在查看结果是中出现乱码时:jmeter的bin目录下的jmeter.properties下最下面添加sampleresult.default.encoding=UTF-8后重新打开工具就好了 在接口的 ...

  9. oracle之三rman 不完全恢复

    rman 不完全恢复 9.1 rman 不完全恢复的三个标准模式:基于time.基于scn和基于sequence: 范例1:恢复过去某个时间点误操作,一般使用基于time或scn. 1)环境:有一套全 ...

  10. 乔悟空-CTF-i春秋-Web-Backdoor

    2020.09.05 每次遇到不会的,想两分钟就放弃了,直接奔wp,一看wp发现,wc,就这?我怎么没想到--心里想着下道题一定自己想,不看wp,然后周而复始