传送门:http://www.lydsy.com/JudgeOnline/problem.php?id=1008
水题。。。
#include <cstdio> const int mod = 100003; long long m, n; inline int poww(long long di, long long mi) { int i; for (i = 63; mi >> i & 1 ^ 1; --i); long long rt = di; for (--i; ~i; --i) { rt = rt * rt % mod; if (mi >> i & 1) { rt = rt * di % mod; } } return (int)rt; } int main(void) { scanf("%lld%lld", &m, &n); printf("%d\n", (poww(m, n) - (m * poww(m - 1, n - 1) % mod) + mod) % mod); return 0; }
时间: 2024-11-03 17:56:58