Cod sursa(job #368715)

Utilizator biroBiro Alexandru biro Data 25 noiembrie 2009 17:35:31
Problema Factorial Scor 95
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.68 kb
#include <stdio.h>

int main()
{
    freopen ( "fact.in" , "r" , stdin ) ;
    freopen ( "fact.out", "w" , stdout) ; 
    
    int i , p , s , k ;

    scanf ( "%d" , &p ) ;

    for( int i=4*p ; i<=5*p ; i++ ) 
        {
            int k=i ;        
            s=0 ;
            while ( k )
            {
                s+=k/5 ;
                k/=5 ;
            }
            if ( s==p )
            {
                printf ( "%d" ,i ) ;
                return 0 ; 
            }
            if ( s>p )
            {
                printf("%d" , -1 );
                return  0 ;
            }
        }
      printf("%d" , 1 );  
    }