题目:

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. 使用pymysql循环删除重复数据,并修改自增字段偏移值

    创建表: CREATE TABLE `info` ( `id` tinyint NOT NULL AUTO_INCREMENT, `name` varchar(20) NOT NULL, PRIMAR ...

  2. 将已经基本完成的项目推送到gitee上管理

    1,首先在gitee上创建仓库,保留一个.gitigonore就行,这样就得到一个远程仓库地址 2,仓库有文件,那么就需要先将这个文件pull下来: 在本地的项目目录中执行:git init git ...

  3. deepin修改数据源升级到deepin15.11桌面版

    参考:https://blog.csdn.net/baidu_41751590/article/details/89064220 1,我修改数据源地址: 换成上海交通大学源地址: http://ftp ...

  4. Python + unittest知识点回顾

    postman 安装Newman 先安装node.js,把npm添加到环境变量中. npm install newman --registry=https://registry.npm.taobao. ...

  5. virtualbox结合nat和host-only设置固定ip的环境

    需求 平时在做一些实验或学习的时候,比如rocketmq.kafaka.zookeeper等,需要在虚拟机上创建几个虚拟机组成集群来做实验:一般有两个要求: 虚拟机能访问网络,需要下载安装东西 虚拟机 ...

  6. [考试总结]noip模拟20

    第五场,再挂分就没了.. 然后就没了.. 考场上一直想方法. 似乎想到了 \(T1\) 正解. 然而几个 \(k\) 的调试信息都让我迷失了自我. 然后有几句啥都没用的语句加在了上面.. 挂分... ...

  7. 利用C++11可变模板,封装调用dll导出函数

    起因 开发中经常需要动态调用一些导出函数,试着利用C++11特性封装一下 尝试 常规使用 typedef int WINAPI (*TMessageBoxA)(HWND hWnd,LPCSTR lpT ...

  8. Django中ORM是啥?

    ORM是啥是许多Django新手的苦恼. ORM中的"O"就是object,也就是我们说的对象:R指的是relations关系:M指的是mapping也就是映射.所以ORM是对象- ...

  9. C#曲线分析平台的制作(二,echarts前后台数据显示)

    在上一篇博客中,学习了使用javascript和jquery两种方法来进行前后台交互.本篇博客着重利用jquery+echarts来实现从后台取数,从前端echarts中展示. 1.html页面编写: ...

  10. 还不了解一下 Java 8 Predicate 函数接口

    同学你好,这里有一份你的未读代码,等你查收. 这篇文章属于 Java 8 教程(LTS)系列教程,点击阅读更多相关文章. Predicate 函数接口同之前介绍的 Function 接口一样,是一个函 ...