Pagini recente » Cod sursa (job #1594464) | Cod sursa (job #1874846) | Cod sursa (job #1217068) | Monitorul de evaluare | Cod sursa (job #1772947)
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("fact.in");
ofstream fout("fact.out");
long p , i , step;
long power(int n){
long pow = 5 , t = 0;
while ( pow <= n )
{
t += n / pow;
pow *= 5;
}
return t;
}
int main()
{
fin >> p;
step = 1<<30;
while(step != 0){
if(power(i + step) < p)
i += step;
step /= 2;
}
i++;
if(power(i) == p) fout << i;
else fout << "-1";
return 0;
}