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)的更多相关文章
随机推荐
- 编写jquery插件的分享
一.类级别($.extend) 类级别你可以理解为拓展jquery类,最明显的例子是$.ajax(...),相当于静态方法. 开发扩展其方法时使用$.extend方法,即jQuery.extend(o ...
- Windows Live Writer配置测试
文字可以了 不知道代码怎么发布
- HDU 1251 统计难题【字典树】
题意:中文题--跟着模板敲的--第一棵字典树--@_@ #include<iostream> #include<cstdio> #include<cstring> ...
- postgresql大批量数据导入方法
一直没有好好关注这个功能,昨天看了一下,数据库插入有瓶颈,今天研究了一下: 主要有以下方案: 1.使用copy从文件导入: copy table_001(a, b, "f", d, ...
- postgresql之数据字典
greenplum是基于postgresql开发的分布式数据库,里面大部分的数据字典是一样的.我们在维护gp的时候对gp的数据字典比较熟悉,特此分享给大家.在这里不会详细介绍每个字典的内容,只会介绍常 ...
- warning:performSelector may cause a leak because its selector
warning:performSelector may cause a leak because its selector 在ARC项目中使用 performSelector: withObj ...
- ecshop init.php文件分析(转)
<?php /** * ECSHOP 前台公用文件 */ //防止非法调用 defined-判断常量是否已定义,如果没返回false if (!defined('IN_ECS')) { die( ...
- web.xml文件的作用
每个javaEE工程中都有web.xml文件,那么它的作用是什么呢?它是每个web.xml工程都必须的吗? 一个web中可以没有web.xml文件,也就是说,web.xml文件并不是web工程必须的. ...
- android webview 遇到的问题:external/chromium/net/disk_cache/stat_hub.cc:216:
今天也遇到这个问题,界面显示无法访问,Baidu吧,结果有些含糊其词,有的说加网络权限,我看了下我的, 有个 <uses-permission android:name="androi ...
- [Everyday Mathematics]20150221
设 $y_n=x_n^2$ 如下归纳定义: $$\bex x_1=\sqrt{5},\quad x_{n+1}=x_n^2-2\ (n=1,2,\cdots). \eex$$ 试求 $\dps{\vl ...