1008: [HNOI2008]越狱
思路:组合数学
补集转化一下
简单的乘法原理
代码:
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#define MOD 100003
using namespace std;
typedef long long ull;
ull n,m;
ull power(ull x,ull k)
{
ull re=1LL;
while (k) {
if (k&1)
re=re*x%MOD;
x=x*x%MOD;
k>>=1; }
return re;
}
void init()
{
cin>>m>>n;
cout<<(power(m,n)+MOD-m*power(m-1,n-1)%MOD)%MOD<<endl;
}
int main()
{
freopen("bzoj1008.in","r",stdin);
freopen("bzoj1008.out","w",stdout);
init();
fclose(stdin);
fclose(stdout);
return 0;
}