题目
代码
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int mod = 100003;
LL m, n;
LL fast(LL base, LL expo)
{
LL result = 1;
while(expo)
{
if(expo & 1)
{
result = result * base % mod;
}
base = base * base % mod;
expo >>= 1;
}
return result;
}
int main()
{
cin >> m >> n;
cout << (fast(m, n) - (m * fast(m-1, n-1) % mod) + mod) % mod;
return 0;
}
感想
别以为减法就不需要mod了,万一是个负数怎么办??而且是(负数+mod)% mod !