Cod sursa(job #274022)

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

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



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

int fact(long long 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,ok=1;
              while(ok&&k<=p*q) { if (fact(k)%a==0) {ok=0; g<<k;}
                          else k++;
                        }  
                    
              return 0;
}