Pagini recente » Monitorul de evaluare | Rating Avram Mihai (mihaiavram96) | Cod sursa (job #952429) | Cod sursa (job #952053) | Cod sursa (job #1720568)
#include <iostream>
#include <fstream>
using namespace std;
long pow5(long);
int main()
{
long p;
long i,n,x;
n = 1;
i = 1;
ifstream fin("fact.in");
ofstream fout("fact.out");
fin >> p;
while (p > 0){
n = i * 5;
x = pow5(i);
p = p -x -1;
i++;
}
if (p == 0)
fout << n;
else fout << -1;
return 0;
}
long pow5(long x){
long exp = 0;
while (x % 5 == 0){
exp++;
x = x/5;
}
return exp;
}