Cod sursa(job #2402948)
Utilizator | Data | 11 aprilie 2019 10:16:23 | |
---|---|---|---|
Problema | Factorial | Scor | 50 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.52 kb |
#include <fstream>
using namespace std;
ifstream f("fact.in");
ofstream g("fact.out");
int p,st,dr,mij,gasit,rez;
int zero(int x)
{
int nr=0;
while (x)
{
nr+=x/5;
x=x/5;
}
return nr;
}
int main()
{
f>>p;
st=1,dr=100000000;
while (st<=dr && gasit==0)
{
mij=(st+dr)/2;
if (zero(mij)>=p)
{
rez=mij;
dr=mij-1;
}
else
st=mij+1;
}
g<<rez;
return 0;
}