Pagini recente » Cod sursa (job #1394647) | Cod sursa (job #1210780) | Cod sursa (job #742934) | Cod sursa (job #2463027) | Cod sursa (job #2748542)
#include <fstream>
#include <cmath>
using namespace std;
int f(int x){
int p = 5, k = 0;
while(x / p > 0){
k = k + x / p;
p *= 5;
}
return k;
}
ifstream cin("fact.in");
ofstream cout("fact.out");
int main()
{
int p, k, x = 0;
cin >> p;
if(p == 0){
cout << 1;
}
else {
k = sqrt(p);
x = k;
while(f(x) < p){
x += k;
}
x -= k;
while(f(x) < p){
x ++;
}
if(f(x) > p){
cout << "-1";
}
else {
cout << x;
}
}
return 0;
}