Cod sursa(job #198801)

Utilizator TrumpCardPopescu Silviu TrumpCard Data 15 iulie 2008 07:59:11
Problema Factorial Scor 60
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.63 kb
 #include <stdio.h> 
long P;
/*long desc(long x)
{int i, j, t=0;
    for(i=1;i<=x;i++) {j=i; 
                       while (j%5==0) {t++;j=j/5;}  
                      }  
 t++;
}*/
 int main()   
 {  
     freopen("fact.in", "r", stdin);  
     scanf("%ld", &P);  
     fclose(stdin);  
     int m,j,c=0;  
      //for(m=1;desc(m)<P;m++);
     for(m=5;c<P;m+=5) {j=m;  
                       while (j%5==0) {c++;j=j/5;}  
                      }  
     freopen("fact.out", "w", stdout);  
     if(P==0) printf("%d", 1);
     else if (c==P) printf("%d", m-5);
         else printf("%d", -1);   
     fclose(stdout);  
     return 0;  
 }