Cod sursa(job #29960)

Utilizator accxelAlex Carp accxel Data 11 martie 2007 22:32:29
Problema Factorial Scor 10
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.79 kb
#include<fstream>
using namespace std;
int main()
{
        long int n=1,prod,p,i,cnt,gasit=0;
        ifstream f("fact.in");
        ofstream g("fact.out");
        f>>p;
        while(!gasit){
                cnt=0;
                prod=1;
                for(i=1;i<=n;i++)
                        prod=prod*i;
                for(i=1;i<=p;i++){
                        if(prod%10==0&&prod!=0){
                                cnt++;
                                prod/=10;
                        }
                        else
                                i=p;
                }
                if(cnt==p)
                        gasit=1;
                else
                        n++;
        }
        g<<n;
        f.close();
        g.close();
        return 0;
}