Pagini recente » Cod sursa (job #3261196) | Cod sursa (job #2709856) | Cod sursa (job #2828714) | Viata de dupa olimpiade? (I) | Cod sursa (job #2353876)
#include <bits/stdc++.h>
#define PMAX 21000000000
#define LL long long int
using namespace std;
ifstream f ("fact.in");
ofstream g ("fact.out");
LL n;
LL nz(LL x){
LL p = 5 , rez = 0;
while(p <= x)
{
rez += x/p;
p = p * 5;
}
return rez;
}
LL cb(){
LL st = 1 , dr = PMAX , mij = 0 , mini = -1;
while(st <= dr)
{
mij = st + (dr - st) / 2;
if(nz(mij) >= n)
{
mini = mij;
dr = mij - 1;
}
else st = mij + 1;
}
return mini;
}
int main()
{
f>>n;
g<<cb();
return 0;
}