Pagini recente » Cod sursa (job #2647635) | Cod sursa (job #1041658) | Cod sursa (job #1115358) | Cod sursa (job #1390903) | Cod sursa (job #3185606)
#include <iostream>
#include <fstream>
using namespace std;
ofstream fout ("fact.out");
ifstream fin ("fact.in");
int main()
{
int i, p, chestie=5,s=0,l=0,r=2e9,mij=0,poz=0;
fin >> p;
poz=0;
l=0;
r=2e9;
while (l<=r)
{
mij=(l+r)/2;
s=0;
chestie=5;
while (chestie<=mij)
{
s=s+mij/chestie;
chestie=chestie*5;
}
if (s<p)
{
l=mij+1;
}
else
{
poz=mij;
r=mij-1;
}
}
fout << poz;
return 0;
}