Cod sursa(job #363193)

Utilizator drujbarultudorTudor Mihai Munteanu drujbarultudor Data 12 noiembrie 2009 09:51:38
Problema Factorial Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.42 kb
#include<cstdio> 
const int N=1<<9; 
int p; 
int zero (int n) 
{  
int s=0; 
while (n) 
{     
s+=n/5;     
n=n/5; 
} 
return s; 
}   
int fact(int p) 
{     
int i,pas=N;     
for ( i=0;pas!=1;pas>>1)    
if (zero(i+pas)<p)         
i+=pas; 
return (i+1); 
} 
int main() 
{ 
freopen("fact.in","r",stdin); 
freopen("fact.out","w",stdout); 
scanf("%d",&p); 
int k=fact(p); 
printf("%d",k); 
return 0; 
}