Mai intai trebuie sa te autentifici.
Cod sursa(job #2330376)
| Utilizator | Data | 28 ianuarie 2019 12:06:41 | |
|---|---|---|---|
| Problema | Factorial | Scor | 0 |
| 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 zerof(unsigned long long n)
{
int nrz=0,p5=5;
while(p5<=n)
{
nrz=nrz+n/p5;
p5*=5;
}
return nrz;
}
int main()
{
unsigned long long mijl,max=1000000000000000000,min=0,gasit=0,n,nr;
//cout<<max;
fin>>n;
while(min<=max && !gasit)
{
mijl=(min+max)/2;
nr=zerof(mijl);
if(nr==n)
gasit=1;
if(nr>n)
max=mijl-1;
else
min=mijl+1;
}
if(gasit==0)
fout<<"-1";
else
fout<<mijl/5*5;
return 0;
}
