约数之和

  • 虽然mod=9901是质数,但也并非所有数都存在乘法逆元,需要特判9901的倍数的情况
#include <bits/stdc++.h>
using namespace std;
const int mod=9901;
int p[15],c[15],tot;
int power(int n,int p)
{
	if(p==0)
	{
		return 1;
	}
	long long tmp=power(n,p/2);
	if(p%2==1)
	{
		return tmp*tmp%mod*n%mod;
	}
	return tmp*tmp%mod;
}
void fac(int x)
{
	int i=2;
	while(i*i<=x)
	{
		if(x%i==0)
		{
			tot++;
			p[tot]=i;
			while(x%i==0)
			{
				c[tot]++;
				x/=i;
			}
		}
		i++;
	}
	if(x>1)
	{
		tot++;
		p[tot]=x;
		c[tot]=1;
	}
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a,b;
	cin>>a>>b;
	if(a==0)
	{
		cout<<0<<endl;
		return 0;
	}
	fac(a);
	long long ans=1;
	for(int i=1;i<=tot;i++)
	{
		c[i]*=b;
		if((1-p[i])%mod==0)
		{
			ans=ans*(c[i]+1)%mod;
		}
		else
		{
			ans=ans*(1-power(p[i],c[i]+1))%mod*power(1-p[i],9899)%mod;
		}
	}
	cout<<(ans+mod)%mod<<endl;
	return 0;
}
posted @ 2025-03-07 15:04  D06  阅读(44)  评论(0)    收藏  举报
//雪花飘落效果