Pagini recente » Autentificare | Monitorul de evaluare | Borderou de evaluare (job #2375868) | Cod sursa (job #1464653) | Cod sursa (job #3304653)
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("fact.in");
ofstream fout("fact.out");
int P, st, dr, mij;
int Nr0(int x)
{
int s = 0;
while(x)
{
s += x / 5;
x /= 5;
}
return s;
}
int main()
{
fin >> P;
st = 1, dr = 5 * 1e8;
if(P == 0)
{
fout << 1;
return 0;
}
while(st <= dr)
{
mij = (st + dr) / 2;
int x = Nr0(mij);
if(x == P)
{
fout << mij - mij % 5;
return 0;
}
else if(x > P)
dr = mij - 1;
else
st = mij + 1;
}
fout << -1;
return 0;
}