Cod sursa(job #958029)

Utilizator thewildnathNathan Wildenberg thewildnath Data 6 iunie 2013 20:20:21
Problema GFact Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.7 kb
#include<stdio.h>
#include<math.h>

int v[20];

int main()
{
    freopen("gfact.in","r",stdin);
    freopen("gfact.out","w",stdout);
    int p,q,i,j=0,nr=0,max=0;
    long long b=1,prod=1;
    scanf("%d%d",&p,&q);
    p=pow(p,q);

    while(p%2==0)
    {
        p=p/2;
        j++;
    }
    if(j>0)
        v[++nr]=pow(2,j);
    for(i=3;i<=p;i+=2)
    {
        j=0;
         while(p%i==0)
        {
            p=p/i;
            j++;
        }
        if(j>0)
            v[++nr]=pow(i,j);
    }

    for(i=1;i<=nr;i++)
        if(v[i]>max)
            max=v[i];


    while(prod<max)
    {
        b++;
        prod=prod*b;
    }

    printf("%d\n",b);
    return 0;
}