Pagini recente » Cod sursa (job #2035502) | Cod sursa (job #79249) | Cod sursa (job #2292595) | Cod sursa (job #1662276) | Cod sursa (job #342205)
Cod sursa(job #342205)
#include <cstdio>
#define file_in "gfact.in"
#define file_out "gfact.out"
long long p,q;
inline long long power(long long a, long long b)
{
long long x;
if (b==1)
return a;
else
if (b%2==0)
{
x=power(a,b/2);
return (x*x);
}
else
{
x=power(a,b/2);
return ((x*x)*a);
}
}
inline long long solveq()
{
long long i,nr;
nr=1;
i=1;
while(nr%p!=0)
{
i++;
nr*=i;
//i++;
}
return i;
}
inline long long solve()
{
long long rez=1,nr=1;
while(rez%p!=0)
{
nr++;
rez*=nr;
}
return nr;
}
int main()
{
int i;
freopen(file_in,"r",stdin);
freopen(file_out,"w",stdout);
scanf("%lld %lld", &p,&q);
if (q==1)
printf("%lld", solve());
else
{
p=power(p,q);
printf("%lld", solve());
}
//}
fclose(stdin);
fclose(stdout);
return 0;
}