Pagini recente » Cod sursa (job #2045993) | Cod sursa (job #3192298) | Cod sursa (job #1925334) | Monitorul de evaluare | Cod sursa (job #1429044)
#include <fstream>
using namespace std;
ifstream fin("fact.in");
ofstream fout("fact.out");
long long nmax = 1 << 25, n, k = 1, x;
long cinci(long n)
{
long x = 0;
for(long i = 5; i <= n; i *= 5)
x += n / i;
return x;
}
int main()
{
fin >> n;
k = x = nmax;
for(; k; k /= 2)
if(x - k >= 0 && cinci(x - k) >= n) x -= k;
if(x == nmax || cinci(x) != n) fout << -1;
else if(x > 0) fout << x;
else fout << 1;
return 0;
}