过度工整代码在线求调
查看原帖
过度工整代码在线求调
796094
封禁用户楼主2023/7/30 12:47

#82

#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define int long long
#define il inline
#define re register
#define endl '\n'

const int maxn=5e7+1;
const int mod=9901;
int pow(int a,int b)
{
	int res=1;
	while(b>0)
	{
		if(b&1)
		{
			res=(res*a)%mod;
		}
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}
int a,b;
vector<int>zs;
bool flag[maxn];
int cnt[maxn];
int inv[maxn];
int ans=1;
vector<pair<int,int>>v;

void work()
{
	for(int i:zs)
	{
		if(a==1)
		{
			break;
		}
		while(a%i==0)
		{
			cnt[i]++;
			a/=i;
		}
		cnt[i]*=b;
		if(cnt[i]!=0)
		{
			v.push_back({i,cnt[i]});
		}
	}
	bool flag2=false;
	for(pair<int,int>i:v)
	{
		ans*=(pow(i.first,i.second+1)-1)%mod*inv[(i.first-1)%mod]%mod;
		ans%=mod;
		flag2=true;
	}
	cout<<(ans%mod+mod)%mod<<endl;
}

void init()
{
	zs.push_back(2);
	memset(flag,true,sizeof(flag));
	for(int i=3;i*i<=maxn;i++)
	{
		if(flag[i])
		{
			zs.push_back(i);
		}
		for(int j:zs)
		{
			if(i*i*j*j>maxn)
			{
				break;
			}
			flag[i*j]=false;
		}
	}
	inv[1]=1;
	for(int i=2;i<mod;i++)
	{
		inv[i]=(mod-mod/i)*inv[mod%i]%mod;
	}
	cin>>a>>b;
}

signed main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	init();
	work();
	return 0;
}
2023/7/30 12:47
加载中...