Cod sursa(job #464266)

Utilizator ionut2219Muresanu Gabriel Ionut ionut2219 Data 19 iunie 2010 15:37:52
Problema Factorial Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.46 kb
#include<iostream.h>
#include<fstream.h>
main()
{ long n,p,i,i2,c,ok=1,ok2,ci;

ifstream f("fact.in");
ofstream g("fact.out");

cin>>p;
c=0;
i=0;
while(ok==1)
{ i++;ok2=1;i2=0;
	ci=i;	
	while(ci!=0 && ok2==1)
 {if(ci%5==0)i2++;
	else ok2=0;
 
   ci=ci/5;
 
}
if(i2>1)c++;
ci=i;ok2=1;
	while(ci!=0 && ok2==1)
 {if(ci%5==0)c++;
	else ok2=0;
 if(c>=p)ok=0;
   ci=ci/5;
 
}
}
if(c==p || c==p+1){n=i;
cout<<n<<" ";}
if(c==p+2)cout<<"-1";
}