Cod sursa(job #2636510)
| Utilizator | Data | 18 iulie 2020 15:33:58 | |
|---|---|---|---|
| Problema | Factorial | Scor | 90 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.69 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("fact.in");
ofstream fout("fact.out");
int n;
int nrz(int x)
{
int s;
s = 0;
while(x!=0)
{
s += x/5;
x/=5;
}
return s;
}
int bsearch(int st,int dr)
{
int sol=1;
while(st<=dr)
{
int mj=(dr+st)/2;
int x=nrz(mj);
if(x<n)
{
st=mj+1;
}
else if(x>n)
{
dr=mj-1;
}
else
{
sol=mj;
dr=mj-1;
}
}
return sol;
}
int main()
{
fin>>n;
fout<<bsearch(1,2000000000);
return 0;
}
