HD2144Calculate S(n)
Problem Description
Calculate S(n).
S(n)=13+23 +33 +......+n3 .
Input
Each line will contain one integer N(1 < n < 1000000000). Process to end of file.
Output
For each case, output the last four dights of S(N) in one line.
Sample Input
1
2
Sample Output
0001
0009#include<iostream>
#include<cmath>
using namespace std;
int main()
{
__int64 n,sum;
while(cin>>n)
{
n = n%10000;
sum=((n*(n+1)/2)*(n*(n+1)/2))%10000;
printf("%04I64d\n",sum);
}
return 0;
}
公式的话,可以用数学归纳法推。
HD2144Calculate S(n)的更多相关文章
随机推荐
- source idea of Unit
After the construction of Global environment setting code, there is a convenient way for us in the f ...
- 修改Eclipse格式化代默认长度
eclipse 默认设置的换行长度为80, 格式化代码后,同一个方法里面参数也经常被,换行,非常难看 1.Java代码打开Eclipse的Window菜单,然后 Preferences->Jav ...
- WEBUS2.0 In Action - 索引操作指南(2)
上一篇:WEBUS2.0 In Action - 索引操作指南(1) | 下一篇:WEBUS2.0 In Action - 搜索操作指南(1) 3. 添加.删除.撤销删除和修改文档 在WEBUS中要将 ...
- notebook kernels
http://10.139.97.132/user/8e6ef01ea71d3f988e61bf2db17c3031/api/kernels [{"id": "f0987 ...
- android 项目随记一
1. requestWindowFeature(); requestWindowFeature可以设置的值有: // 1.DEFAULT_FEATURES:系统默认状态,一般不需要指定 ...
- 【英语】Bingo口语笔记(2) - 吞音
- type tips
网上有这么一篇文章,全文如下:http://bbs.9ria.com/blog-220191-18429.html AS3中一共有以下六种获取变量类型的方法: typeof instanceof ...
- DB time实时过程分析
在我们查看awr报告的时候总是会有一个关键指标需要注意,那就是DB time,这个指标一般都是通过awr报告来看到的.比如我们得到的awr报告头部显示的下面的信息,我们就清楚的知道DB time是15 ...
- Java核心技术II读书笔记(一)
Char2 XML 解析器:读入一个文件,确认其具有正确的格式,然后将其分解成各种元素,使程序员能够访问这些元素. java库提供了两种XML解析器:DOM和SAX,即文档对象模型和流机制解析器. D ...
- 实现LoaderCallbacks接口动态循环加载网上图片并展示在手机屏幕上 ...
1.布局xml文件 activity_main.xml <RelativeLayout xmlns:android="http://schemas.android.com/apk/re ...