The series, 11 + 22 + 33 + … + 1010 = 10405071317.
Find the last ten digits of the series, 11 + 22 + 33 + … + 10001000.
Answer:
9110846700
#include<bits/stdc++.h>
using namespace std;
const long long mod=10000000000;
const long long digs=1e5;
long long multimod(long long n,long long m)
{
long long a,b,c,d,ans=0;
a=n/digs;b=n%digs;
c=m/digs;d=m%digs;
ans=(ans+(((a*digs)%mod)*d))%mod;
ans=(ans+(((b*digs)%mod)*c))%mod;
ans=(ans+b*d)%mod;
return ans;
}
int main()
{
long long ans=0;
for(long long i=1;i<=1000;i++)
{
long long sum=1;
long long z=i;
long long k=i;
while(z)
{
if(z%2) sum=multimod(sum,k)%mod;
k=multimod(k,k)%mod;
z/=2;
}
ans=(ans+sum)%mod;
}
cout<<ans%mod<<endl;
}