Problem 6
Problem 6
# Problem_6.py
"""
The sum of the squares of the first ten natural numbers is,
12 + 22 + ... + 102 = 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
找出100一下的所有自然数的平方和与这些自然数的和的平方之间的差数.
"""
sum_of_squares = sum([i*i for i in range(1, 101)])
square_of_sum = pow(sum([i for i in range(1, 101)]), 2) print(square_of_sum, '-', sum_of_squares, '=', square_of_sum-sum_of_squares)
Problem 6的更多相关文章
- 1199 Problem B: 大小关系
求有限集传递闭包的 Floyd Warshall 算法(矩阵实现) 其实就三重循环.zzuoj 1199 题 链接 http://acm.zzu.edu.cn:8000/problem.php?id= ...
- No-args constructor for class X does not exist. Register an InstanceCreator with Gson for this type to fix this problem.
Gson解析JSON字符串时出现了下面的错误: No-args constructor for class X does not exist. Register an InstanceCreator ...
- C - NP-Hard Problem(二分图判定-染色法)
C - NP-Hard Problem Crawling in process... Crawling failed Time Limit:2000MS Memory Limit:262144 ...
- Time Consume Problem
I joined the NodeJS online Course three weeks ago, but now I'm late about 2 weeks. I pay the codesch ...
- Programming Contest Problem Types
Programming Contest Problem Types Hal Burch conducted an analysis over spring break of 1999 and ...
- hdu1032 Train Problem II (卡特兰数)
题意: 给你一个数n,表示有n辆火车,编号从1到n,入站,问你有多少种出站的可能. (题于文末) 知识点: ps:百度百科的卡特兰数讲的不错,注意看其参考的博客. 卡特兰数(Catalan):前 ...
- BZOJ2301: [HAOI2011]Problem b[莫比乌斯反演 容斥原理]【学习笔记】
2301: [HAOI2011]Problem b Time Limit: 50 Sec Memory Limit: 256 MBSubmit: 4032 Solved: 1817[Submit] ...
- [LeetCode] Water and Jug Problem 水罐问题
You are given two jugs with capacities x and y litres. There is an infinite amount of water supply a ...
- [LeetCode] The Skyline Problem 天际线问题
A city's skyline is the outer contour of the silhouette formed by all the buildings in that city whe ...
- PHP curl报错“Problem (2) in the Chunked-Encoded data”解决方案
$s = curl_init(); curl_setopt($s, CURLOPT_POST, true); curl_setopt($s, CURLOPT_POSTFIELDS, $queryStr ...
随机推荐
- spring中abstract bean的使用方法
什么是abstract bean?简单来说.就是在java中的继承时候,所要用到的父类. 案例文件结构: 当中Person类为父类.Student类为子类,其详细类为: package com.tes ...
- IOS UITextView光标位置在中间的问题
在viewDidLoad中 if ([selfrespondsToSelector:@selector(setAutomaticallyAdjustsScrollViewInsets:)]) { se ...
- DotNetBar.Bar菜单的使用
DotNetBar.Bar菜单的使用 老帅 在C#中使用控件DevComponents.DotNetBar.Bar时,怎样设计菜单呢? 1.拖放生成一个菜单容器 拖放一个D ...
- SQL SEVER 元年是1900年
用SQL语句求 本月第一天,怎么写? 可以这样写: SELECT DATEADD(mm,DATEDIFF(mm,0,GETDATE()),0); 按照日期函数DATEDIFF的定义,第二个参数是开始日 ...
- '无法将“vue”项识别为 cmdlet、函数、脚本文件或可运行程序的名称' 或 'vue不是内部或外部命令' 的解决方法
如果在使用 vue 初始化项目的时候提示: vue : 无法将“vue”项识别为 cmdlet.函数.脚本文件或可运行程序的名称.请检查名称的拼写,如果包括路径,请确保路径正确,然后再试一次. 或者: ...
- Node.js:创建第一个应用
ylbtech-Node.js:创建第一个应用 1.返回顶部 1. Node.js 创建第一个应用 如果我们使用PHP来编写后端的代码时,需要Apache 或者 Nginx 的HTTP 服务器,并配上 ...
- 微阅读,不依赖playground,打包成H5版本--案例学习
微阅读,不依赖playground,打包成H5版本 https://github.com/vczero/weex-yy-h5
- 中文分词--最大正向与逆向匹配算法python实现
最大匹配法:最大匹配是指以词典为依据,取词典中最长单词为第一个次取字数量的扫描串,在词典中进行扫描(为提升扫描效率,还可以跟据字数多少设计多个字典,然后根据字数分别从不同字典中进行扫描).例如:词典中 ...
- eclipse中文汉字看不清或过小的问题解决方法!!
把字体修改为 中欧字体就可以看清汉字
- Python 之 风格规范(Google )
开头先mark一下网址:goole官网 任何语言的程序员,编写出符合规范的代码,是开始程序生涯的第一步. 一.分号 不要在行尾加分号, 也不要用分号将两条命令放在同一行. 二.行长度 每行不超过80个 ...