Pagini recente » Cod sursa (job #2679604) | Cod sursa (job #2696735) | Cod sursa (job #2720357) | Cod sursa (job #2631177) | Cod sursa (job #2131175)
#include <fstream>
#define ll long long
using namespace std;
ifstream fin("fact.in");
ofstream fout("fact.out");
ll nrz(ll x)
{
ll k = 0;
while(x > 4) {
x /= 5;
k+=x;
}
return k;
}
int main()
{
ll n;
fin >> n;
ll k;
if(n == 0)
fout << "1";
else {
bool ok = true;
int i = n + n - nrz(5 * k);
k = i;
while(nrz(5 * k) != n) {
k += (n - nrz(5 * k));
if(i == k) {
ok = false;
break;
}
}
fout <<((ok) ? 5 * k : -1);
}
return 0;
}