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)的更多相关文章

随机推荐

  1. 详解Android中的屏幕方向

    屏幕方向 是对Activity而言的,所以你可以在AndroidManifest.xml 文件中,通过<activity> 标记的screenOrientation 属性进行设定,例如: ...

  2. git大文件管理

    由于git在每一个commit时都会变动过的文件全部保存(不像其他的系统,只做文件增量存储),外加未变动文件的引用,这样如果在文件系统中有一些大的二进制文件,比如图片,视频,那么很快你的repo就将变 ...

  3. ASP.NET 时间方法大全

    DateTime dt = DateTime.Now; //当前时间 DateTime startWeek = dt.AddDays(- Convert.ToInt32(dt.DayOfWeek.To ...

  4. 旧书重温:0day2【1】 简单的缓冲区溢出案例

    0x01 准备: VMwarePlayer (我是在360软件管家那搜到的下载的) xp sp2 http://user.qzone.qq.com/252738331/blog/1357138598 ...

  5. InputStream重用技巧(利用ByteArrayOutputStream)

    有时候我们需要对同一个InputStream对象使用多次.比如,客户端从服务器获取数据 ,利用HttpURLConnection的getInputStream()方法获得Stream对象,这时既要把数 ...

  6. linux中备份mysql数据库的一个shell脚本

    #!/bin/bash #FileName:select_into_bak.sh #Desc:Use select into outfile to backup db or tables #Creat ...

  7. erl0007 - erlang 远程节点连接的两种方式

    启动连接:erl -setcookie abc -name xxx@192.168.x.x -remsh xxx@192.168.x.y 退出:ctrl + g,q 参考:http://www.cnb ...

  8. jquery中html()/text()/val()区别

    html就是你可以添加<span></span><li></li>的标记text只能写文本如果写了上面的标记则会以文本形式输出,就是输出标签体的内容va ...

  9. web.xml整合s2sh内容

    <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http:// ...

  10. 【英语】Bingo口语笔记(12) - Put系列

    put off 推迟