Cod sursa(job #1910060)
Utilizator | Data | 7 martie 2017 15:23:17 | |
---|---|---|---|
Problema | Factorial | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.48 kb |
#include <fstream>
using namespace std;
ifstream f("fact.in");
ofstream g("fact.out");
long long p,l,x,nr,y,i,u,z,m;
int zero(int x)
{
int nr=0,l=5;
while(l<=x)
{
nr=nr+x/l;
l=l*5;
}
return nr;
}
int main()
{
f>>z;
p=1;
u=z*5;
while(p<=u)
{
m=(p+u)/2;
if(zero(m)>=z) u=m-1;
else p=m+1;
}
if(z==0) g<<"1";
else if(zero(p)==z) g<<p;
else g<<"-1";
return 0;
}