Pagini recente » Cod sursa (job #1747721) | Cod sursa (job #2792561) | Cod sursa (job #1134731) | Cod sursa (job #606958) | Cod sursa (job #1974902)
#include <fstream>
#include <limits.h>
using namespace std;
ifstream f ("factorial.in");
ofstream g ("factorial.out");
long long p;
long long sum;
int main(){
f >> p;
if(!p){
g << 1 << '\n';
return 0;
}
for(long long i = 5; i <= LLONG_MAX; i += 5){
if (i % 5 == 0){
long long k = i;
while(k % 5 == 0){
++sum;
k /= 5;
}
}
if (p == sum){
g << i << '\n';
break;
}
else if(sum > p){
g << -1 << '\n';
break;
}
}
}