Cod sursa(job #2534932)
| Utilizator | Data | 31 ianuarie 2020 09:41:18 | |
|---|---|---|---|
| Problema | Factorial | Scor | 25 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.59 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin ("fact.in");
ofstream fout ("fact.out");
int zerouri(int x)
{
int cnt=0;
while(x>0)
{
cnt+=x/5;
x/=5;
}
return cnt;
}
int main()
{
int p,st,dr,mj;
fin >> p;
st=1;
dr=100000001;
mj=(st+dr)>>1;
while(dr-st>1)
{
mj=(st+dr)>>1;
if(zerouri(mj)<p)
{
st=mj;
}
else
{
dr=mj;
}
}
if(p==0)
mj=1;
fout << mj;
return 0;
}
