hdu-2114-Calculate S(n)
2015-08-09 16:53
495 查看
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
前n项立方和的公式:(n*(n+1)/2)^2;,注意这里要用__int64,用int会一直WA
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
前n项立方和的公式:(n*(n+1)/2)^2;,注意这里要用__int64,用int会一直WA
#include<iostream> #include<cstring> #include<cstdio> using namespace std; int main() { __int64 n,i; while(cin>>n) { n=n%10000; i=(((n*(n+1)/2))*((n*(n+1)/2)))%10000; printf("%04I64d\n",i); } return 0; }
相关文章推荐
- 为什么你宁愿每周工作90小时,也不做任何改变?(转载)
- 使用代码为textview设置drawableLeft
- 大苏格兰2015年中学等级考试的一道初等数学题
- Java查看List扩容后的容量
- 10.1——pair,map,set,multimap,multiset
- OpenGl编程指南例2.4大白话分析
- MVC简单实现查询列表
- Leetcode52 N-Queens II
- MongoDB查询
- sp_send_dbmail参数设置
- 常见MFC UI界面库
- 《how tomcat work》 搬运工 Chapter 5: Container
- JavaScript我学之七数组
- 音乐录像带第三版之与音乐同步输出图形
- 无法打开包括源文件"extensions/cocos-ext.h"
- php调用c++程序例子
- sql------【二】
- Bean的作用域及初始化
- POJ 3641 Pseudoprime numbers
- 廖雪峰javascrip学习笔记<高级>