Pagini recente » Cod sursa (job #431334) | Cod sursa (job #1416979) | Cod sursa (job #1346128) | Cod sursa (job #1915979) | 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;
}