Pagini recente » Cod sursa (job #3175820) | Autor necunoscut | Istoria paginii runda/de_placere/clasament | Cod sursa (job #1507703) | Cod sursa (job #2588616)
#include <iostream>
#include <cmath>
#include <fstream>
using namespace std;
ifstream f("fact.in");
ofstream g("fact.out");
int nr5(int x){
int s=0;
for(int n=5;n<=x and n>0;n*=5){
s+=x/n;
}
return s;
}
int main(int argc, char const *argv[])
{
int p,li=0,mid,lf,gas=-1,k;
f>>p;
lf=p;
if(p==0)g<<1;
else{
do{
mid=(li+lf)/2;
k=nr5(5*mid);
if(k==p)gas=5*mid;
else if(k>p)lf=mid-1;
else li=mid+1;
}while(li<=lf && k!=p);
if(gas==-1)cout<<-1;
else g<<gas;
}
return 0;
}