Pagini recente » Istoria paginii runda/concurs_info2018 | Rating Marcu Luca (Marcu_Luca_._.) | Cod sursa (job #853008) | Cod sursa (job #2437548) | Cod sursa (job #342207)
Cod sursa(job #342207)
#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 solve()
{
long long rez=1,nr=1;
while(rez%p!=0)
{
nr++;
rez*=nr;
}
return nr;
}
int main()
{
freopen(file_in,"r",stdin);
freopen(file_out,"w",stdout);
scanf("%lld %lld", &p,&q);
if (q==1)
{
int x;
//printf("%lld", solve());
while(1)
x++;
}
else
{
p=power(p,q);
printf("%lld", solve());
}
//}
fclose(stdin);
fclose(stdout);
return 0;
}