Pagini recente » Cod sursa (job #1548219) | Cod sursa (job #2355938) | Cod sursa (job #2175115) | Cod sursa (job #2858679) | Cod sursa (job #3141305)
#include <iostream>
using namespace std;
typedef unsigned long long ull;
ull fact5(ull x)
{
int k = 0;
while(x)
k += x/5, x /= 5;
return k;
}
int main()
{
freopen("fact.in", "r", stdin);
freopen("fact.out", "w", stdout);
ull p; cin >> p;
ull index = 0;
for(int bit = 63; bit >= 0; bit--)
{
index += ull(1<<bit);
if(fact5(index) >= p) index -= ull(1<<bit);
}
index++;
if(p == fact5(index)) cout << index;
else cout << -1;
return 0;
}