Cod sursa(job #2078109)

Utilizator Hidden.bdBurlacu Doru Hidden.bd Data 28 noiembrie 2017 22:10:20
Problema Factorial Scor 25
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.58 kb
#include <fstream>


using namespace  std;
ifstream fin("fact.in");
ofstream fout("fact.out");
             
int main(  )
{
    long long p;
    int nrZero;
    fin >> p;
    bool gasit = false;
    if( p == 0 ){
        fout << 1;
        return 0;
    }
    
    for( long long i = p * 4 ; i <= 1000 ; ++i ){
        
        nrZero = 0;
        for( int j = 5 ; j <= i ; j *= 5 ){
            nrZero += i / j;
        }
        
        if( nrZero == p ){
            gasit = true;
            fout << i;
            break;
        }
    }
    
    
    
    
    if( !gasit ) fout << -1;
}