Pagini recente » Borderou de evaluare (job #1458445) | Cod sursa (job #615144) | Cod sursa (job #262065) | Cod sursa (job #1224963) | Cod sursa (job #2256031)
#include <iostream>
#include <fstream>
using namespace std;
int main(){
int n = 0, p = 0, z = 0;
long long f;
ifstream in("fact.in");
ofstream out("fact.out");
in >> p;
if(p == 0){
out << 1 << endl;
return 0;
} else {
n = 4 * p;
n = n - n%5;
f = 5;
while(f <= n){
z = z + n / f;
f = f * 5;
}
}
while(z<p)
n += 5;
f = n;
while(f % 5 == 0){
++z;
f /= 5;
}
}
if(z == p){
out << n << endl;
} else {
out << -1 << endl;
}
}