Pagini recente » Cod sursa (job #90348) | Cod sursa (job #925264) | Cod sursa (job #541042) | Cod sursa (job #1075995) | Cod sursa (job #1769421)
#include <cstdio>
using namespace std;
inline long long cnt (int x) {
long long nr = 0;
while (x >= 5) {
nr += x / 5;
x /= 5;
}
return nr;
}
const int NMAX = 1 << 30;
int main() {
freopen("fact.in","r",stdin);
freopen("fact.out","w",stdout);
int i,pas,p;
scanf("%d",&p);
pas = 1 << 30;
i = 0;
while (pas) {
if (i + pas <= NMAX && cnt(i + pas) < p)
i += pas;
pas /= 2;
}
if (cnt(i + 1) == p)
printf("%d",i + 1);
else
printf("-1");
return 0;
}