Cod sursa(job #1470868)

Utilizator razvan700razvan popescu razvan700 Data 12 august 2015 15:50:27
Problema Factorial Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.64 kb
#include <fstream>
using namespace std;
ifstream fin("fact.in");
ofstream fout("fact.out");

int main()
{
    int p,n=1,i,r,f=1,j,ok;
    fin>>p;
    if(p>100000000)
    {
        fout<<-1;
        return 0;
        fin.close();
        fout.close();
    }
    while(ok!=0)
    {
        f=1;
        for(i=1;i<=n;i++)
        {
            f=f*i;
        }
        ok=0;
        for(j=1;j<=p;j++)
        {
            r=f%10;
            if(r!=0)
            {
                ok=1;
            }
            f=f/10;
        }
        n++;
    }
   fout<<n-1;
   fin.close();
   fout.close();
    return 0;
}