题目:

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.

这个也太简单了,不过如果用笔算的话肯定很难,需要思考一番

 1 #include<iostream>
2 using namespace std;
3
4 int main() {
5 int N = 100;
6 int squareofsum = ((1+N)*N/2)*((1+N)*N/2);
7 int sumofaquare = 0;
8 for(int i = 1; i <= N; i++) {
9 sumofaquare += i*i;
10 }
11 cout << squareofsum - sumofaquare << endl;
12 system("pause");
13 return 0;
14 }

ProjectEuler 006题的更多相关文章

  1. ProjectEuler 做题记录

    退役选手打发时间的PE计划 挂在这里主要是dalao们看到有什么想交流的东西可以私聊哦(站内信或邮箱吧)~~当然现在高三也不怎么能上网. 2017/8/11  595 :第一题QAQ 2017/8/1 ...

  2. ProjectEuler 005题

    题目: 2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any ...

  3. ProjectEuler 009题

    题目: A Pythagorean triplet is a set of three natural numbers, a b c, for which, a2 + b2 = c2 For exam ...

  4. ProjectEuler 008题

    题目: The four adjacent digits in the 1000-digit number that have the greatest product are 9 9 8 9 = 5 ...

  5. ProjectEuler 007题

    题目:By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is ...

  6. ProjectEuler 004题

    1 #include<iostream> 2 using namespace std; 3 4 int main() { 5 bool isPalindromic (int num); 6 ...

  7. ProjectEuler 003题

    1 //题目:The prime factors of 13195 are 5, 7, 13 and 29. 2 //What is the largest prime factor of the n ...

  8. nim也玩一行流,nim版的list comprehension

    nim 是一门风格类似python的静态编译型语言,官方网站:http://nim-lang.org 如果你想折腾nim的编辑环境,可以用sublime text3 +插件nimlime,notepa ...

  9. ProjectEuler && Rosecode && Mathmash做题记录

    退役选手打发时间的PE计划 挂在这里主要是dalao们看到有什么想交流的东西可以私聊哦(站内信或邮箱吧) 2017/8/11  PE595 :第一题QAQ 2017/8/12  PE598 2017/ ...

随机推荐

  1. linux xsel命令

    xsel操作在三个寄存器上,其中一个是系统剪切板(-b).一个是默认寄存器(-p).一个是(-s)

  2. sql-3-DML_DQL

    DML-操作数据 1.insert语句 --增加一行数据 insert into 表名([字段1,字段2,字段3,...])values('值1','值2','值3',...); insert int ...

  3. 虚拟机安装RHEL8.0.0

    在VMware Workstations 15.0.0中安装RHEL8.0.0 使用到的软件和主机基本配置 此处宿主机基本硬件配置:i3-7100U 4核,内存:12G 虚拟化软件:VMware Wo ...

  4. 接口开发---basic auth接口认证

    开发中遇到了basic auth来认证的案例,这里总结一下: Basic Auth简单点说明就是每次请求API时都提供用户的username和password.[base64encode(userna ...

  5. 第九篇 -- cpu的学习

    CPU的核数关系: 总核数 = 物理CPU个数 X 每颗物理CPU的核数 总逻辑CPU数 = 物理CPU个数 X 每颗物理CPU的核数 X 超线程数 Linux中查看CPU数: # 查看物理CPU个数 ...

  6. 痞子衡嵌入式:深扒i.MXRTxxx系列ROM中集成的串行NOR Flash启动SW Reset功能及其应用场合

    大家好,我是痞子衡,是正经搞技术的痞子.今天痞子衡给大家介绍的是i.MXRTxxx系列ROM中集成的串行NOR Flash启动SW Reset功能及其应用场合. 在串行 NOR Flash 热启动过程 ...

  7. Mac搭建Vue开发环境

    1.安装Homebrew /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/ ...

  8. C++员工管理系统(封装+多态+继承+分类化+函数调用+读写文件+指针+升序降序算法等一系列知识结合)

    1 C++职工管理系统 2 该项目实现 八个 功能 3 1-增加功能 2-显示功能 3-删除功能 4-修改功能 4 5-查找功能 6-排序功能 7-清空功能 8-退出功能 5 实现多个功能使用了多个C ...

  9. 学习Android Jetpack? 入门教程和进阶实战这里全都有!

    前言 2018年谷歌I/O,Jetpack横空出世,官方介绍如下: Jetpack 是一套库.工具和指南,可帮助开发者更轻松地编写优质应用.这些组件可帮助您遵循最佳做法.让您摆脱编写样板代码的工作并简 ...

  10. .Net Core+分布式配置中心(AgileConfig)

    GitHub上AgileConfig非常详细,以下只是本人学习过程的整理 一.介绍 1.参考地址 https://github.com/dotnetcore/AgileConfig https://w ...