洛谷 P3197 [HNOI2008]越狱

越狱

(咕咕咕)


Code:

#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
using namespace std;
//Mystery_Sky
//
#define M 1000100
#define ll long long
#define Mod 100003
ll n, m;
ll quickPow(ll x, ll k)
{
	ll ret = 1;
	while(k) {
		if(k & 1) ret = (ret * x) % Mod;
		k >>= 1;
		x = (x * x) % Mod;
	}	
	return ret % Mod;
} 

int main() {
	scanf("%lld%lld", &m, &n);
	printf("%lld\n", (quickPow(m, n) - (m * quickPow(m-1, n-1)) % Mod + Mod) % Mod);
	return 0;
}
posted @ 2019-07-02 20:52  Mystery_Sky  阅读(125)  评论(0编辑  收藏  举报