Codeforces - Math

Topic links: codeforces - the Math


Topic effect: a you a number, you can take a number, or the square root of the number of minimum requirements and minimum number can get.

After the first prime factor decomposition, we can see that each prime factor will only be to eliminate only one. Then all of the highest quality have become as a result of power several times, and has been prescribing can be.


AC Code:

#pragma GCC optimize("-Ofast","-funroll-all-loops")
#include<bits/stdc++.h>
#define int long long
using namespace std;
int n,res=1,ans,flag,mx=1,k=1;	map<int,int> mp;
signed main(){
	cin>>n;
	for(int i=2;i*i<=n;i++){
		while(n%i==0)	mp[i]++,n/=i;
	}
	if(n>1)	mp[n]++;
	for(auto x:mp){
		res*=x.first;	mx=max(mx,x.second);
	}
	for(auto x:mp)	if(x.second<mx)	flag=1;
	while(k<mx)	k<<=1;	ans=max(1LL*(k!=mx),flag);
	while(k>1)	ans++,k>>=1;
	cout<<res<<' '<<ans;
	return 0;
}
Published 483 original articles · won praise 241 · views 30000 +

Guess you like

Origin blog.csdn.net/weixin_43826249/article/details/104101845
Recommended