Cod sursa(job #784533)

Utilizator RusuRusu Daniel Rusu Data 6 septembrie 2012 11:28:23
Problema Factorial Scor 25
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.39 kb
#include <fstream>
using namespace std;
ifstream fin("fact.in");
ofstream fout("fact.out");
long t5,aux,n,p,nr=5;
int main()
 {fin>>p;
  if(p==0) fout<<"1";
  else
   {while(p>0)
     {aux=nr;
	  while(aux%10==0) {p--;aux/=10;}
	  t5=0;
      while(aux%5==0) {t5++;aux/=5;}
	  p-=t5;
	  if(p<=0) break;
	  nr+=5;
	 }
	fout<<nr;
   }
  fin.close();
  fout.close();
  return 0;
 }