(Problem 6)Sum square difference
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.
前十个自然数的平方和是:
前十个自然数的和的平方是:
所以平方和与和的平方的差是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的更多相关文章
- (Problem 57)Square root convergents
It is possible to show that the square root of two can be expressed as an infinite continued fractio ...
- (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 ...
- (Problem 13)Large sum
Work out the first ten digits of the sum of the following one-hundred 50-digit numbers. 371072875339 ...
- (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 ...
- (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 ...
- (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 ...
- (Problem 37)Truncatable primes
The number 3797 has an interesting property. Being prime itself, it is possible to continuously remo ...
- (Problem 36)Double-base palindromes
The decimal number, 585 = 10010010012(binary), is palindromic in both bases. Find the sum of all num ...
- (Problem 35)Circular primes
The number, 197, is called a circular prime because all rotations of the digits: 197, 971, and 719, ...
随机推荐
- kafka集群配置与测试
刚接触一些Apache Kafka的内容,用了两天时间研究了一下,仅以此文做相关记录,以供学习交流. 概念: kafka依赖的项: 1. 硬件上,kafka利用线性存储来进行硬盘直接读写. 2. k ...
- ORA-20000: ORU-10027: buffer overflow, limit of 10000 bytes
要用dbms_output.put_line来输出语句,遇到以下错误: ERROR 位于第 1 行: ORA-20000: ORU-10027: buffer overflow, limit ...
- Oracle中SQL语句学习五(统计分组语句group by和having)
oracle(41) 在 应用系统开发中,进行需要统计数据库中的数据,当执行数据统计时,需要将表中的数据进行分组显示,在统计分组中是通过group by子句.分组函数.having子句共同实现的.其中 ...
- Protel99se教程二:使用protel99se原理图绘制
使用protel99se绘制原理图,首先要先设置一下显示网格这一项,这个可以根据个人习惯,并不是一定需要这样的,在prote99se的界面的View菜下,将visible Grid选中或取消,可以选择 ...
- QT太多的内容和模块,怎么办?
我有个问题,QT可以做许多不同的开源项目,而且每个QT新版本都那么内容,感觉学不过来.用不过来那么我们还应该学习和使用其它语言吗? 如果回答,在需要的时候学习,那么这句话意味着,这几年你基本上就局限于 ...
- 代码收藏 JS实现页内查找定位功能
前部分为IE下搜索方法 用TextRange来实现 后部分为firefox.chrome下搜索方法 var nextIndex = 0; var searchValue = ''; var input ...
- QT在ui文件上建立信号操机制会不会对后期维护产生影响 - love4Mario的专栏 - 博客频道 - CSDN.NETQT在ui文件上建立信号操机制会不会对后期维护产生影响 - love4Mario的专栏 - 博客频道 - CSDN.NET
QT在ui文件上建立信号操机制会不会对后期维护产生影响 - love4Mario的专栏 - 博客频道 - CSDN.NET QT在ui文件上建立信号操机制会不会对后期维护产生影响 分类: 学习心得 2 ...
- config -导航
在config进行中配置 1在config中添加SITmap <siteMap enabled="true" defaultProvider="UserSiteM ...
- SVN使用技巧
安装 下载SVN服务端:VisualSVN Server https://www.visualsvn.com/downloads/ 安装,下一步...(更改地址,Location是安装目录,Repos ...
- Codeforces Round #316 (Div. 2C) 570C Replacement
题目:Click here 题意:看一下题目下面的Note就会明白的. 分析:一开始想的麻烦了,用了树状数组(第一次用)优化,可惜没用. 直接判断: #include <bits/stdc++. ...