Cod sursa(job #2278230)

Utilizator Dragomiralexandru621@yahoo.comDragomir ionut alexandru [email protected] Data 7 noiembrie 2018 15:08:55
Problema Factorial Scor 30
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.47 kb
#include <fstream>
#include <iostream>
using namespace std;
ifstream f("fact.in") ;
ofstream g("fact.out") ;
int x ;
int nrv , nr = 5 , nrp = 1 ;
int main()
{
    f >> x ;
if( x == 0 )
    g << 1 ;
else
{

 while( nrp < x )
        {
        nrv = nr ;
        while ( nrv % 5 == 0 )
        {
            nrv = nrv / 5 ;
            nrp ++ ;
        }
        nr += 5 ;
    }
    if( nrp == x )
        g << nr ;
    else
        g << "-1" ;
}
}