Cod sursa(job #1711548)
| Utilizator | Data | 31 mai 2016 17:10:04 | |
|---|---|---|---|
| Problema | Factorial | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.45 kb |
#include <fstream>
using namespace std;
ifstream fin("fact.in");
ofstream fout("fact.out");
long long p,bot=1,top=1000000000,mid,z;
int nrnada(int h)
{int nr=0;
while(h>=5)
{
nr+=(h/=5);
}
return nr;
}
int main()
{
fin>>p;
if(!p)fout<<1;
else{while(bot<=top)
{
mid=(bot+top)/2;
z=nrnada(mid);
if(z>=p)top=mid-1;
else bot=mid+1;
}
if(nrnada(bot)==p)fout<<bot;
else fout<<-1;
}
return 0;
}
