标签:
原题链接:http://www.lydsy.com/JudgeOnline/problem.php?id=1008
就很傻逼的组合数学啊。。。
$$ans=M^N-M*(M-1)^{(N-1)}$$
/************************************************************** Problem: 1008 User: HarryGuo2012 Language: C++ Result: Accepted Time:0 ms Memory:1272 kb ****************************************************************/ #include<iostream> #include<cstring> #include<vector> #include<cstdio> using namespace std; typedef long long ll; const ll mod=100003; ll Pow(ll a,ll b) { ll res = 1; while (b) { if (b & 1)res = (res * a) % mod; a = (a * a) % mod; b >>= 1; } return res; } ll M,N; int main() { scanf("%lld%lld", &M, &N); printf("%lld\n", (M*mod + Pow(M, N) - M * Pow(M - 1, N - 1)) % mod); return 0; }
标签:
原文地址:http://www.cnblogs.com/HarryGuo2012/p/4845345.html