提交时间:2023-08-25 09:28:38

运行 ID: 100216

#include<bits/stdc++.h> #define int long long using namespace std; const int mod = 1e5 + 3; int fastpow(int a,int b){ int sum = a,ans = 1; while (b){ if (b & 1){ ans = (ans * sum) % mod; } sum = (sum * sum) % mod; b >>= 1; } return ans; } signed main(){ int n,m; cin>>m>>n; cout<<(fastpow(m % mod,n) - (fastpow((m - 1) % mod,n - 1) * m) % mod + mod) % mod<<'\n'; return 0; }