Cod sursa(job #2404949)
| Utilizator | Data | 13 aprilie 2019 16:59:50 | |
|---|---|---|---|
| Problema | Factorial | Scor | 20 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.46 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("fact.in");
ofstream fout("fact.out");
short cif( int m, int n )
{
int c = 0, f = 5;
while( f <= m )
{
c += m/f;
f *= 5;
}
if( c > n )
return -1;
return ( c == n );
}
int main()
{
int n, m = 1;
fin >> n;
while( cif(m, n) == 0 )
++m;
if( cif(m, n) == -1 )
fout << -1;
else
fout << m;
return 0;
}
