Cod sursa(job #1934068)

Utilizator lazaralex2002Lazar Alex Constantin lazaralex2002 Data 21 martie 2017 09:25:14
Problema Factorial Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.65 kb
#include <iostream>
#include <cstdio>
using namespace std;
FILE*fin=fopen("fact.in","r");
FILE*fout=fopen("fact.out","w");
int main()
{
    long long n , p , k = 0 , x , i , k1 = 0  , j ;
    cin >> p ;
    for ( i = 1 ; i <= p * 5  ; ++i )
    {
        if ( i % 5 == 0 )
        {
            x = i ;
            if ( ( i / 5 ) % 5 == 0 )
            {
                while ( x % 5 == 0 )
                {
                    ++k ;
                    x /= 5 ;
                }
            }
            else ++k ;
        if ( k >= p ) break ;
        }
    }

    if ( k == p ) cout << i ;
    else cout << "-1" ;
    return 0;
}