Cod sursa(job #323621)

Utilizator mentallysafenotPerian Bogdan mentallysafenot Data 12 iunie 2009 21:28:34
Problema Factorial Scor 30
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.67 kb
#include <fstream>
#include <iostream>

using namespace std;
fstream f,g;
long p;
long x;
long d,c;

int main()
{
    f.open("fact.in",fstream::in);
    f >> p;
    g.open("fact.out",fstream::out);
    if(p==0)
    {
       g << "1\n";
       g.close();
       return 0;        
    }
    long y,i,aux;
    y=0;
    
    for(i=1;;i++)
    {
     aux = i;
       while(aux%5==0)
       {
              aux/=5;
              y++;   
       }    
       if(y == p)
       {
         g << i << "\n";
         g.close();    
         return 0;
       }
       if(i>=10*p)
         break;
    }
    
    g << "-1\n";
    g.close();    
    return 0;
}