Cod sursa(job #108128)

Utilizator rethosPaicu Alexandru rethos Data 21 noiembrie 2007 17:11:31
Problema Factorial Scor 20
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.41 kb
#include <fstream.h>
#define tip_i float
int div(tip_i x)
{ long long s=0;
  while ((long long)x%5==0)
	{ s++;x=x/5;}
  return s;
}
int main()
{ long long p,nr=0;
  tip_i i=0;
  ifstream f("fact.in");
  ofstream g("fact.out");
  f>>p;
  f.close();
  while (nr<p)
	{ i++;
	  nr+=div(i);
	}
  if (i==0) { g<<1;g.close();return 0;}
  if (nr==p) g<<i;
	 else g<<-1;
  g.close();
  return 0;
}