Cod sursa(job #348282)
Utilizator | Data | 15 septembrie 2009 10:12:19 | |
---|---|---|---|
Problema | GFact | Scor | 20 |
Compilator | cpp | Status | done |
Runda | Papiu Contest #1 | Marime | 0.42 kb |
#include<stdio.h>
int p,q,s,i,j;
int rez;
int main()
{
freopen("gfact.in","r",stdin);
freopen("gfact.out","w",stdout);
scanf("%d%d",&p,&q);
for(i=2;p>1;++i)
for(;p%i==0;p/=i);
--i;
for(j=2 , s=1 ; s+j<=q ; s+=j , ++j);
--j;
rez=1;
for(int b=i;j;j/=2 , b*=i)
if (j%2==1)
rez*=b;
printf("%d\n",rez);
return 0;
}