Cod sursa(job #2748542)
Utilizator | Data | 1 mai 2021 13:04:42 | |
---|---|---|---|
Problema | Factorial | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.64 kb |
#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;
}