题目https://www.luogu.com.cn/problem/P1630
喜闻乐见的代码部分
//洛谷P1630 求和
#include<iostream>
#include<cstdio>
#define m 10000
using namespace std;
long long c[10010];
long long add[10010];
long long fastpower(long long base,long long power)
{
long long result =1;
while(power>0)
{
if(power & 1)//power是奇数
result=result*base%m;
power>>=1;//power/=2;
base=(base*base)%m;
}
return result%m;
}
int main()
{
long long n;
long long a,b;
long long sum;
scanf("%ld",&n);
for(int j=0;j<n;j++)
{
sum=0;
scanf("%ld%ld",&a,&b);
for(int i=1;i<=10000;i++)
{
c[i]=fastpower(i,b);
add[i]=(add[i-1]+c[i])%m;
}
sum=((add[10000]*((a/10000)%m))%m+add[a%10000])%m;
printf("%ld\n",sum);
}
}