Cod sursa(job #273990)

Utilizator cryowarCristian Barbu cryowar Data 9 martie 2009 12:16:57
Problema GFact Scor 10
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.46 kb
#include<iostream>
#include<math.h>
#include<fstream>

using namespace std;
long long p,a;
int q;
long b;


ifstream f ("gfact.in");
ofstream g ("gfact.out");

int fact(int x)
{
    if(x==0||x==1) return 1;
    else return x*fact(x-1);
}

int main()
{             f>>p>>q;
              a=pow(p,q);
      
              int k=1;
              for(int i=1;i<=p*q && k;i++) if(fact(i) % a==0) {k=0;b=i;}
      
              g<<b;
return 0;
}