Pagini recente » Cod sursa (job #1872643) | Cod sursa (job #2536660) | Cod sursa (job #1577938) | Cod sursa (job #2258668) | Cod sursa (job #1515976)
#include<iostream>
#include<fstream>
#include<climits>
using namespace std;
ifstream fin("fact.in");
ofstream fout("fact.out");
int zero(int m){
int p=5,k=0;
while(p<=m){
k=k+m/p;
p=p*5;
}
return k;
}
int main(){
int i,j,m,p;
bool ok;
fin>>p;
if(p==0)fout<<"1";
i=1;j=INT_MAX;ok=false;
while(i<=j&&!ok){
m=(i+j)/2;
if(zero(m)==p)ok=true;
else if(zero(m)<p)i=m+1;
else j=m-1;
}
if(ok){
m=m-m%5;
fout<<m<<" ";
}
else fout<<"-1";
return 0;
}