Cod sursa(job #734175)

Utilizator Paula-ElenaPaula-Elena Margarit Paula-Elena Data 13 aprilie 2012 19:18:13
Problema Factorial Scor 20
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.75 kb
# include <fstream>
using namespace std ; 

int main ( )
{   
    ifstream fin("fact.in") ;
    ofstream fout("fact.out") ;
    
    long long P , c = 0 , N = 0, a = 0 , b ;
    
    fin >> P ; 
    
    if(P == 0) N = 1 ;
    else while(c < P) {
                        a = 0 ;
                        N = N + 5 ;
                        b = N ;
                        while((b % 5 == 0) && (b > 0)) {
                                                        a++ ;
                                                        b = b / 5 ; 
                                                       }
                        c = c + a ;
                       }
    
    fout << N ; 
    
    fin.close ( ) ;
    fout.close ( ) ;
    return 0 ;
}