裸的快速幂
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <cstring>
#include <cmath>
const int mod=100003;
using namespace std;
int main()
{
long long n, m, s1, s2, t, po;
while(~scanf("%lld%lld",&m,&n)){
t=n, po=m, s1=1;
while(t){
if(t%2)
s1=s1*po%mod;
po=po*po%mod;
t/=2;
}
t=n-1, po=m-1, s2=m;
while(t){
if(t%2)
s2=s2*po%mod;
po=po*po%mod;
t/=2;
}
printf("%lld\n",(s1-s2+mod)%mod);
}
return 0;
}