Cod sursa(job #617544)

Utilizator eloredanaAlbulescu Elena-Loredana eloredana Data 15 octombrie 2011 00:07:36
Problema Factorial Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.58 kb


#include <iostream>
#include <fstream>
using namespace std;


void main()
{   int n,nz,p,ok=0; 
	fstream f("fact.in", ios::in);
	fstream g("fact.out", ios::out);
    if (f==NULL) { cout<<"Probleme la deschiderea fisierului"; return 13; }
    f>>p; 
	 n=1; nz=0; 
	  while (nz<p)
	  {   
		 nz=0;
	     for (int j=1; j<=n; j++)
	       {  int i=j;
		      while (i%5 == 0) { nz++;
			                     i/=5; 
			                   }
	       }
		 if (nz==p) 	 { g<<n; ok = 1;break; }
		 else
		  n++;
	  }
	  if (ok==0) g<<"-1";
	  g.close();
	  f.close();

}