Pagini recente » Cod sursa (job #2137508) | Monitorul de evaluare | Diferente pentru template/algoritmiada-2009/header intre reviziile 25 si 3 | Diferente pentru template/preoni-2007 intre reviziile 14 si 13 | Cod sursa (job #1793894)
#include<iostream>
#include<fstream>
using namespace std;
ifstream fin("fact.in");
ofstream fout("fact.out");
long long n, p, min1 = 9999999999;
bool ver(long long x)
{
long long tot = 0;
while(x)
{
tot += x / 5;
x /= 5;
}
if(tot >= p)
{
return 1;
}
return 0;
}
void cautbin(long long p, long long u)
{
if(p <= u)
{
int mid = (p + u) / 2;
if(ver(mid))
{
if(mid < min1) min1 = mid;
cautbin(p, mid - 1);
}
else cautbin(mid + 1, u);
}
}
int main()
{
fin>>p;
cautbin(1, 100000000);
fout<<min1;
}