题解 | [HNOI2008]越狱

[HNOI2008]越狱

https://www.nowcoder.com/practice/33d5016548d84cbe8cdb08ca0c13c2f1

#include<bits/stdc++.h>
using namespace std;
#define int long long
const int P=100003;

int power(int a,int b,int p){
	int ans=1;
	while(b>0){
		if(b&1==1){
			ans=ans*a%p;
		}
		a=a*a%p;
		b=b>>1;
	}
	return ans;
}

int n,m;


signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>m>>n;
	
	int res=(power(m,n,P)%P-m%P*power(m-1,n-1,P)%P+P)%P;
	
	cout<<res<<endl;

    return 0;
}


全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务