Pagini recente » Viata de dupa olimpiade? (partea I) | Cod sursa (job #3286943) | Cod sursa (job #799521) | Cod sursa (job #3285038) | Cod sursa (job #2353885)
#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 = 0;
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;
if(cb())g << cb();
else g << -1;
return 0;
}