Cod sursa(job #286151)

Utilizator mihaimoldovanMihai Moldovan mihaimoldovan Data 23 martie 2009 15:36:16
Problema Factorial Scor 15
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.33 kb
#include<fstream>
using namespace std;
int main()
{
 int p,n=0,e;
 ifstream fin("fact.in");
 fin>>p;
 fin.close();
 ofstream fout("fact.out");
 if(p==0)n=1;
 if(p>400000)n=-1,p=-1;
 while(p)
    {
     n+=5;
     p--;
     e=n;
     e/=5;
     while(e%5==0)e/=5,p--;
    }
 fout<<n;
 fout.close();
 return 0;
}