Pagini recente » Cod sursa (job #2072000) | Cod sursa (job #1743274) | Cod sursa (job #2155638) | Cod sursa (job #2366654) | Cod sursa (job #1579315)
#include <fstream>
#include <iostream>
using namespace std;
ifstream fin("fact.in");
ofstream fout("fact.out");
int nrmax=100000000;
int zero(int x) {
int sol=0;
while (x/5!=0) {
sol=sol+x/5;
x=x/5;
}
return sol;
}
int main () {
int n,i,Sol,n2;
fin>>n;
for (n2=1; n2<=5*nrmax; n2*=2) {
}
n2/=2;
Sol=5*nrmax;
for (i=n2; i>0; i/=2)
{
if (Sol-i>=1 && zero(Sol-i)>=n)
Sol=Sol-i;
}
if (zero(Sol)==n)
fout<<Sol<<"\n";
else fout<<"-1\n";
return 0;
}