#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<string>
#include<time.h>
using namespace std;
#define NUM 10000000000
long long fun(long long n)
{
long long t =1;
for(int i=1; i<=n; i++)
{
t = t * n ;
if(t > NUM)
t = t % NUM;
}
return t;
}
int main()
{
int startTime, endTime;
int maxNum = 1000;
long long ret=0;
startTime = clock();
for(int i=1;i<=maxNum;i++)
{
if(i % 10 == 0)
continue;
ret += fun(i);
if(ret> NUM)
ret = ret % NUM;
}
cout << "(1^1+2^2+...+1000^1000) %1000000000 = "<< ret<<endl;
endTime = clock();
double duringTime = (double)(endTime - startTime) / 1000;
printf( "%f seconds\n", duringTime );
return 0;
}