Cod sursa(job #564216)

Utilizator UgleaEduFMI - Edward UgleaEdu Data 26 martie 2011 22:03:29
Problema Factorial Scor 5
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.5 kb
#include <iostream>
#include <fstream>
using namespace std;
int main ()
{
 unsigned int nrzero = 0 , p ;
 long int i , j = 10 ;
 fstream f("fact.in",ios::in );
 f >> p ;
 f.close();     
 fstream g ("fact.out",ios::out );
 if(p == 0 ) g << 1 ;
 else
 {
  while ( nrzero < p )
  {
   while( i % 5 == 0  && i < 100 && i != 25 )
   {
    nrzero++;
    i /= 5 ;
   }
   i = j ;
   j += 5 ;
  }
 if( nrzero == p )g<< i - 5 ;
 else g<<-1 ;
 }
 return 0 ; 
}