标签:ble stay higher input ons ash bit sqrt VID
Among many of the Catland club kittens it is important to keep a paw on the pulse of the latest fashions and trends in order to stay hip. When a new number is discovered in Catland, its coolness is primarily determined by its meow factor. For a positive integer n, its meow factor is the largest integer m such that n is evenly divisible by m nine times (once for each life of a cat). We say that n is divisible by m nine times if, starting with n, you can divide it by m without a remainder, take the result of the division and again divide it by m without a remainder, and so on, dividing by m nine times in total.
While some cats are naturally chic and have an innate ability to see the meow factor of numbers, others who struggle to stay in vogue can not even tell the difference between 3584 and 4711 (the former clearly having a higher meow factor). Can you help those poor unfortunate cats lacking a sense of style, by writing a program to determine the meow factor of a number?
Input
The input contains a single integer \(n (1≤n≤26^3?1)\).
Output
Output the meow factor of n.
大概意思就是 给你一个数n,你要求出一个数m,m是能够让 \((n/m)/m...\)这样除以m 九次并且,每次都没有余数 的最大数。
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n;
const int MAXN=100000;
/*int prime[MAXN+2];
void getPrime()
{
memset(prime,0,sizeof(prime));
for(int i=2;i<=MAXN;i++)
{
// printf("i:%d\n",i);
if(!prime[i]) prime[++prime[0]]=i;
for(int j=1;j<=prime[0]&&prime[j]<=MAXN/i;j++)
{
prime[prime[j]*i]=1;
if(i%prime[j]==0) break;
}
}
}
ll factor[100][2];
int fatCnt;*/
/*void getFactors( ll x)
{
fatCnt=0;
ll tmp=x;
for(int i=1;prime[i]<=tmp/prime[i];i++)
{
if(tmp%prime[i]==0)
{
factor[fatCnt][0]=prime[i];
while(tmp%prime[i]==0)
{
factor[fatCnt][1]++;
tmp/=prime[i];
}
fatCnt++;
}
}
if(tmp!=1)
{
factor[fatCnt][0]=tmp;
factor[fatCnt++][1]=1;
}
}*/
map<ll,ll> getFactors(ll x)
{
map<ll,ll> m;
for(ll i=2;i<=min((ll)sqrt(x),1ll*MAXN);i++)
{
while(x%i==0)
{
m[i]++;
x/=i;
}
}
if(x>1)
m[x]++;
return m;
}
int main()
{
scanf("%lld",&n);
map<ll,ll> m = getFactors(n);
ll mx=1;
ll t;
for(auto & i: m)
{
while(i.second >=9)
{
i.second-=9;
mx *= i.first;
}
}
printf("%lld\n",mx);
return 0;
}
标签:ble stay higher input ons ash bit sqrt VID
原文地址:https://www.cnblogs.com/xuwanwei/p/12879736.html