Pagini recente » Cod sursa (job #445759) | Cod sursa (job #2067213) | Cod sursa (job #1038458) | Cod sursa (job #1664781) | Cod sursa (job #3191893)
#include <bits/stdc++.h>
using namespace std;
ifstream fin ("gfact.in");
ofstream fout ("gfact.out");
int d[100001],p[100001],ct,y;
int putere (int n,int z)
{
int nr=0;
while (n>=z)
nr+=(n/=z);
return nr;
}
bool se_divide(int n)
{
for (int i=1; i<=ct; i++){
if (putere(n,d[i])<p[i]*y)
return false;}
return true;
}
int main()
{
int x;
fin>>x>>y;
int a,b;
while(x<a*a)
{
b = 0;
while(x % a == 0)
{
++b;
x /= a;
}
if(b)
{
ct++;
d[ct]=a;
p[ct]=b;
}
++ a;
}
if (x)
{
ct++;
d[ct]=x;
p[ct]=1;
}
long long st=1,dr=100000000000001,r=0;
while (st<=dr)
{
int mij=(st+dr)/2;
if (se_divide(mij)==true)
{
r=mij;
dr=mij-1;
}
else st=mij+1;
}
fout<<r;
return 0;
}