Python练习题 034:Project Euler 006:和平方与平方和之差
本题来自 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:和平方与平方和之差的更多相关文章
- Python练习题 032:Project Euler 004:最大的回文积
本题来自 Project Euler 第4题:https://projecteuler.net/problem=4 # Project Euler: Problem 4: Largest palind ...
- Python练习题 029:Project Euler 001:3和5的倍数
开始做 Project Euler 的练习题.网站上总共有565题,真是个大题库啊! # Project Euler, Problem 1: Multiples of 3 and 5 # If we ...
- Python练习题 046:Project Euler 019:每月1日是星期天
本题来自 Project Euler 第19题:https://projecteuler.net/problem=19 ''' How many Sundays fell on the first o ...
- Python练习题 039:Project Euler 011:网格中4个数字的最大乘积
本题来自 Project Euler 第11题:https://projecteuler.net/problem=11 # Project Euler: Problem 10: Largest pro ...
- Python练习题 033:Project Euler 005:最小公倍数
本题来自 Project Euler 第5题:https://projecteuler.net/problem=5 # Project Euler: Problem 5: Smallest multi ...
- Python练习题 049:Project Euler 022:姓名分值
本题来自 Project Euler 第22题:https://projecteuler.net/problem=22 ''' Project Euler: Problem 22: Names sco ...
- Python练习题 048:Project Euler 021:10000以内所有亲和数之和
本题来自 Project Euler 第21题:https://projecteuler.net/problem=21 ''' Project Euler: Problem 21: Amicable ...
- Python练习题 047:Project Euler 020:阶乘结果各数字之和
本题来自 Project Euler 第20题:https://projecteuler.net/problem=20 ''' Project Euler: Problem 20: Factorial ...
- Python练习题 045:Project Euler 017:数字英文表达的字符数累加
本题来自 Project Euler 第17题:https://projecteuler.net/problem=17 ''' Project Euler 17: Number letter coun ...
随机推荐
- 史上!最最最简洁明了的 Java JDK 安装目录及其子目录含义 10分钟详解 - 精简归纳
Java JDK 安装目录及其子目录含义 10分钟详解 - 精简归纳 JERRY_Z. ~ 2020 / 8 / 30 转载请注明出处!️ 目录 Java JDK 安装目录及其子目录含义 10分钟详解 ...
- 拿捏了!ConcurrentHashMap!
概述 本文将对JDK8中 ConcurrentHashMap 源码进行一定程度的解读.解读主要分为六个部分:主要属性与相关内部类介绍.构造函数.put过程.扩容过程.size过程.get过程.与JDK ...
- 表格取消全选框,用文字表示--Echarts ElementUi
1.先看看实现的图 一. 添加添加复选框列 <el-table v-loading="zongShipLoading" tooltip-effect="dark&q ...
- android开发之splash闪屏页判断是否第一次进入app代码
package com.david.david.zhankudemo.activity; import android.app.Activity; import android.content.Con ...
- basicInterpreter1.01 支持分支语句
源码:https://files.cnblogs.com/files/heyang78/basicInterpreter-20200531-1.rar 输入: count= print(count) ...
- flume读取日志文件并存储到HDFS
配置hadoop环境 配置flume环境 配置flume文件 D:\Soft\apache-flume-1.8.0-bin\conf 将 flume-conf.properties.template ...
- flag在index里
题目:http://123.206.87.240:8005/post/ 我们来看这一题 首先打开题目 他让点击就点击呗 跳转到另一个新的界面 这就没了??? ... 没思路就对了 //假装证明自 ...
- Java 8 Stream API实例
一.开篇 Stream?其实就是处理集合的一种形式,称之为流,在Java8中被引入,可被Collection中的子类调用. 作用?简化代码,提升你的开发效率. 不会?看完这篇你就能自己上手了! 二.实 ...
- oracle数据处理之exp/imp
oracle 导出/导入数据方法一 exp/imp工具:1 将数据库oracle01完全导出,DBA:sys,密码:123456:用户名Scott 密码123456 导出到D:\emp.dmp中 ex ...
- ASP.NET Core 3.x启动时运行异步任务(一)
这是一个大的题目,需要用几篇文章来说清楚.这是第一篇. 一.前言 在我们的项目中,有时候我们需要在应用程序启动前执行一些一次性的逻辑.比方说:验证配置的正确性.填充缓存.或者运行数据库清理/迁移等 ...