http://acm.split.hdu.edu.cn/showproblem.php?pid=2114
Problem Description
Calculate S(n).
S(n)=1 3+2 3 +3 3 +......+n 3 .
S(n)=1 3+2 3 +3 3 +......+n 3 .
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<cstdio>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<string>
#include<set>
#include<vector>
#include<map>
#define ms(x) memset( (x),0,sizeof(x) );
using namespace std;
typedef long long int ll;
ll f(ll a){
return a%10000;
}
int main()
{
ll n;
while(cin>>n){
ll ans=f(f(n+1)*f(n))/2;
ans=ans*ans%10000;
printf("%04lld\n",ans);
}
return 0;
}
ps
1.正整数范围中
