Pagini recente » Cod sursa (job #1618862) | Cod sursa (job #1350661) | Cod sursa (job #1773829) | Cod sursa (job #2565460) | Cod sursa (job #3162380)
#include <fstream>
#include<cmath>
using namespace std;
long long int factori_5(long long int x) {
int cnt = 0;
while (x > 0) {
if (x % 5 == 0) {
x /= 5;
cnt++;
}
if (x % 5 != 0)
break;
}
return cnt;
}
int main() {
ifstream cin("fact.in");
ofstream cout("fact.out");
int p;
cin >> p;
long long int r = 0;
long long i = 5;
if (p == 0)
cout << 1;
else {
while (1) {
p -= factori_5(i);
if (p == 0) {
cout << i;
break;
}
if (p < 0) {
cout << -1;
break;
}
i += 5;
}
}
return 0;
}