Cod sursa(job #348286)

Utilizator hasegandaniHasegan Daniel hasegandani Data 15 septembrie 2009 10:15:21
Problema GFact Scor 5
Compilator cpp Status done
Runda Papiu Contest #1 Marime 0.45 kb
#include<stdio.h>

int p,q,s,i,j,k;
int rez;

int main()
{
    freopen("gfact.in","r",stdin);
    freopen("gfact.out","w",stdout);
    scanf("%d%d",&p,&q);
    
    for(i=2;i<=p;++i)
        if(p%i==0)
            k=i;
    i=k;
        
    
        
    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;
}