Cod sursa(job #805380)

Utilizator sorincusmareIacob Sorin sorincusmare Data 31 octombrie 2012 12:35:19
Problema Factorial Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.43 kb
#include<stdio.h>

int zero(int n){
    int nr=0 ;
    while(n>=5)
        nr+=(n/=5);

return nr;
}

int caut(intx){
    int i=0,pas;
    pas=1<<29;
while (pas!=0)
{ if zero(i+pas<x)
     i +=pas;
     pas /=2;
}
return i+`;
}

int main(){
freopen("fact.in","r",stdin);
freopen("fact.out","w",stdout);
int p,r;
scanf("%d",&p);
r=caut(0)
if(zero(r)==p)
 printf("%d\n",r);
  else
 printf("-1") ;
 return 0;
 }