Cod sursa(job #284677)

Utilizator robigiirimias robert robigi Data 21 martie 2009 21:29:07
Problema Factorial Scor 60
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.6 kb
#include <fstream> 
using namespace std;  
  
ifstream f ("fact.in");   
ofstream g ("fact.out");   
  
  
long x;   
  
long cifre5(long n)   
{    int nr=1;   
     while (n%5==0)   
     {     nr++;   
       n/=5;   
     }   
     return nr;   
}   
  
void program()   
{    f >> x;   
     if (x==0) { g << 1; return; }   
     int ok=1, nr5=0;   
     for (long i=1; ok; i++)   
     {   if (nr5>x) { g << -1; ok=0; }   
     else if (nr5==x) { g << (i-1)*5; ok=0; }   
          else nr5+=cifre5(i);   
     }   
}   
  
int main()   
{   program();   
    return 0;   
}