Cod sursa(job #29975)

Utilizator accxelAlex Carp accxel Data 12 martie 2007 00:42:05
Problema Factorial Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.6 kb
#include<fstream>
#include<math.h>
using namespace std;
long int fact(long int x)
{
        long int i,prod=1;
        for(i=1;i<=x;i++)
                prod=prod*i;
        return prod;
}
int main()
{
        long int n,prod,i,p,gasit=0;
        ifstream f("fact.in");
        ofstream g("fact.out");
        f>>p;
        while(!gasit){
                prod=fact(n);
		i=pow(10,p);
                if((prod%i)%10!=0)
                        gasit=1;
                else
                        n++;
        }
        g<<n;
        f.close();
        g.close();
        return 0;
}