提交时间:2023-08-25 21:13:41

运行 ID: 100438

#include<bits/stdc++.h> using namespace std; int fastpow(int a,int b,int mod){ int num=1; for(int i=1;i<=b;i++){ num*=a; num%=mod; } return num; } int fastpow2(int a,int b,int mod){ int num=1; int temp; if(b==1) return a; if(b==0) return 1; if(b%2==0) { temp = (fastpow2(a,b/2,mod))%mod; return (temp * temp)%mod; } else { temp = (fastpow2(a,(b-1)/2,mod))%mod; return (a * temp * temp)%mod; } } int main(){ int m,n; cin>>m>>n; int a=fastpow2(m,n,10003)%10003; int b=(fastpow2(m-1,n-1,10003)*m)%10003; cout<<(a+10003-b)%10003; return 0; }