求调
  • 板块P1593 因子和
  • 楼主suzhikz
  • 当前回复0
  • 已保存回复0
  • 发布时间2024/5/28 18:47
  • 上次更新2024/5/28 19:25:17
查看原帖
求调
800499
suzhikz楼主2024/5/28 18:47
#include<bits/stdc++.h>
#define ing long long
using namespace std;
const int mod=9901;
int a,b;
int x[300],y[300],tot;
int ans=1;
int pow(int x,int q){
	int book=x,a=1;
	while(q){
		if(q&1){
			a*=book;
			a%=mod;
		}
		book*=book;
		book%=mod;
		q>>=1;
	}
	return a;
}
signed main(){
	cin>>a>>b;
	if(b==0){
		cout<<1;
		return 0;
	}
	for(int i=2;i*i<=a;i++){
		if(a%i==0){
			x[++tot]=i;
			while(a%i==0){
				a/=i;
				y[tot]++;
			}
			y[tot]*=b;
			if((x[tot]-1)%mod==0){
				ans*=(y[tot]+1)%mod;
			}else{
				ans*=(pow(x[tot],y[tot]+1)%mod-1+mod)%mod*pow(x[tot]-1,mod-2);
			} 
			ans%=mod;
		}
	}
	if(a!=1){
		int i=a;
		x[++tot]=i;
		y[tot]=b;
		if((x[tot]-1)%mod==0){
			ans*=(y[tot]+1)%mod;
		}else{
			ans*=(pow(x[tot],y[tot]+1)-1+mod);
            ans%=mod;
			//cout<<ans<<endl;
			ans*=pow(x[tot]-1,mod-2);
		} 
		ans%=mod;
	}
	cout<<ans;
	
	return 0;
}

2024/5/28 18:47
加载中...