Cod sursa(job #16589)

Utilizator robbyRobertino robert robby Data 13 februarie 2007 19:06:01
Problema Factorial Scor 20
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.41 kb
#include <stdio.h>
FILE *f,*g;
long long p,s,i,j;
int main()
{
   FILE *f=fopen("fact.in","rt");
   FILE *g=fopen("fact.out","wt");
   fscanf(f,"%lld",&p);
   s=0;
   i=0;
   while (s<p)
	 {
	   i+=5;
	   j=i;
	   while (j%5==0)
		 {
		   s++;
		   j/=5;
		 }
	 }
   if (!i)
	 i=1;
   if (s!=p)
	 fprintf(g,"%lld",-1);
	else
	  fprintf(g,"%lld",i);
   fclose(f);
   fclose(g);
   return 0;
}