Cod sursa(job #246961)

Utilizator Soimul_NegruIon Popescu Soimul_Negru Data 21 ianuarie 2009 22:09:51
Problema Factorial Scor 30
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.61 kb
#include <iostream.h>
#include <stdio.h>
int main()
{int j,x=0,i;
long p,n=0;

freopen("fact.in", "r", stdin);
freopen("fact.out", "w", stdout);
cin>>p;

if(p==0) {cout<<1; return 0;}
else
 {while(x<p)
   {++x;
    n=n+5;
    if(n%25==0) ++x;
     if(n%125==0) ++x;
      if(n%625==0) ++x;
       if(n%3125==0) ++x;
	if(n%15625==0) ++x;
	 if(n%78125==0) ++x;
	  if(n%390625==0) ++x;
	   if(n%1953125==0) ++x;
	    if(n%9765625==0) ++x;
	     if(n%48828125==0) ++x;
	      if(n%244140625==0) ++x;
	       if(n%1220703125==0) ++x;}
  if(x==p) cout<<n;
  else cout<<-1;}

fcloseall();
return 0;
}