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 ...
随机推荐
- 手把手实现Java权限(1)-Shiro介绍
功能介绍 Authentication :身份认证/登录.验证用户是不是拥有对应的身份: Authorization :授权,即权限验证.验证某个已认证的用户是否拥有某个权限:即推断用 户能否做事 ...
- [think in java]第12章 通过异常处理错误
异常处理是java中唯一正式的错误报告机制. 而且通过编译器强行运行. 异常參数 抛出异常与方法正常返回值的差别:异常返回的"地点"与普通方法调用返回的"地点" ...
- hdoj--1829--A Bug's Life(带权并查集)
A Bug's Life Time Limit: 15000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) To ...
- 【POJ 3071】 Football
[题目链接] http://poj.org/problem?id=3071 [算法] 概率DP f[i][j]表示第j支队伍进入第i轮的概率,转移比较显然 [代码] #include <algo ...
- mysql5.7下面windows平台大小写敏感
转自:https://blog.csdn.net/lrl219/article/details/52889582 根据网上的信息在my.ini下面的mysqld的配置下面添加lower_case_ta ...
- thinkphp 内存查询表 防止多次查库
//从内存查询 表 以防止多次查库 private static function selectTable($tableName,array $where,$getFirst=false){ $res ...
- idea的环境变量设置(Enviroment variables)
- Elasticsearch之curl创建索引库和索引时注意事项
前提, Elasticsearch之curl创建索引库 Elasticsearch之curl创建索引 注意事项 1.索引库名称必须要全部小写,不能以下划线开头,也不能包含逗号 2.如果没有明确指定索引 ...
- C# HttpWebRequest post 请求传参数
Dictionary<string, string> parameters = new Dictionary<string, string>(); //参数列表 paramet ...
- java学习笔记3——异或
异或原理: 转换两个字符或数为2进制的ASCII码,再按位异或,即 0001 0001 ---> 0000 0000 0000 ---> 0000 0001 0000 ---> 00 ...