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.

前十个自然数的平方和是:

12 + 22 + ... + 102 = 385

前十个自然数的和的平方是:

(1 + 2 + ... + 10)2 = 552 = 3025

所以平方和与和的平方的差是3025  385 = 2640.

找出前一百个自然数的平方和与和平方的差。

#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <math.h> #define N 100 int powplus(int n, int k)
{
int s=;
while(k--)
{
s*=n;
}
return s;
} int sum1(int n)
{
return powplus((n+)*n/,);
} int sum2(int n)
{
return (n*(n+)*(*n+))/;
} void solve()
{
printf("%d\n",sum1(N));
printf("%d\n",sum2(N));
printf("%d\n",sum1(N)-sum2(N));
} int main()
{
solve();
return ;
}
Answer:
25164150

(Problem 6)Sum square difference的更多相关文章

  1. (Problem 57)Square root convergents

    It is possible to show that the square root of two can be expressed as an infinite continued fractio ...

  2. (Problem 16)Power digit sum

    215 = 32768 and the sum of its digits is 3 + 2 + 7 + 6 + 8 = 26. What is the sum of the digits of th ...

  3. (Problem 13)Large sum

    Work out the first ten digits of the sum of the following one-hundred 50-digit numbers. 371072875339 ...

  4. (Problem 46)Goldbach's other conjecture

    It was proposed by Christian Goldbach that every odd composite number can be written as the sum of a ...

  5. (Problem 42)Coded triangle numbers

    The nth term of the sequence of triangle numbers is given by, tn = ½n(n+1); so the first ten triangl ...

  6. (Problem 74)Digit factorial chains

    The number 145 is well known for the property that the sum of the factorial of its digits is equal t ...

  7. (Problem 37)Truncatable primes

    The number 3797 has an interesting property. Being prime itself, it is possible to continuously remo ...

  8. (Problem 36)Double-base palindromes

    The decimal number, 585 = 10010010012(binary), is palindromic in both bases. Find the sum of all num ...

  9. (Problem 35)Circular primes

    The number, 197, is called a circular prime because all rotations of the digits: 197, 971, and 719, ...

随机推荐

  1. perl 第十四章 Perl5的包和模块

    第十四章 Perl5的包和模块 by flamephoenix 一.require函数  1.require函数和子程序库  2.用require指定Perl版本二.包  1.包的定义  2.在包间切 ...

  2. VS2010/MFC对话框:非模态对话框的创建及显示

    非模态对话框的创建及显示 上一节讲了模态对话框及其弹出过程,本节接着讲另一种对话框--非模态对话框的创建及显示. 已经说过,非模态对话框显示后,程序其他窗口仍能正常运行,可以响应用户输入,还可以相互切 ...

  3. hdoj 1874 畅通工程续(单源最短路+dijkstra)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1874 思路分析:该问题给定一个无向图.起始点和终点,要求求出从起始点到终点的最短距离: 使用Dijks ...

  4. B - 楼下水题(扩展欧几里德)

    B - 楼下水题 Time Limit:1000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit St ...

  5. android 支持分组和联系人展示的一个小样例

    先看效果图: 要实现这个效果,activity必须实现ExpandableListActivity @Override public void onCreate(Bundle savedInstanc ...

  6. Foundation Sorting: Single List Insertion Sort

    /* List Insertion Sorting. * Implementation history:. * 2013-09-15, Mars Fu, first version. */ #incl ...

  7. Git基础 1 ---- 版本控制系统的介绍

    1 Git 1 版本控制系统 vcs - version control system 2 版本控制是一种记录一个或若干文件内容变化,以便将来查阅特定版本修订情况的系统 3 版本控制系统的主要功能 1 ...

  8. android编译系统的makefile文件Android.mk写法如下

    (1)Android.mk文件首先需要指定LOCAL_PATH变量,用于查找源文件.由于一般情况下Android.mk和需要编译的源文件在同一目录下,所以定义成如下形式:LOCAL_PATH:=$(c ...

  9. HTML5+CSS3正式开课

    HTML5+CSS3 HTML5+CSS3 HTML5+CSS3

  10. 阿里Android一面(校招)

    4.8号晚上8点多接到了阿里一面的电话,面试官人很好,和我聊了半个多小时.我面的是无线事业部,就是做淘宝客户端的那个部门.面试问的都很基础,刚开始问了hashmap和快速排序.接着就是问Android ...