Pagini recente » Cod sursa (job #3207609) | Cod sursa (job #871499) | Cod sursa (job #1481088) | Cod sursa (job #2805334) | Cod sursa (job #591423)
Cod sursa(job #591423)
#include<cstdio>
using namespace std;
long long int c,s,p,aux;
int ok;
int calcul(){
s=0;
while(c!=0){
c/=5;
s+=c;
}
}
int main(){
freopen("fact.in","r",stdin);
freopen("fact.out","w",stdout);
scanf("%lld",&p);
aux=p;
if(aux==0)
printf("%d",1);
else{
if(aux<0)
printf("%d",-1);
else{
ok=1;
if(aux%5==0)
while(aux>5){
aux/=5;
if(aux%5!=0)
ok=0;}
if(aux%5==0 && ok==1)
printf("%d",-1);
else{
c=5*p;
aux=c;
calcul();
if(s<p){
c=aux+5;
while(s!=p){
aux=c;
calcul();
if(s!=p)
c=aux+5;
}
printf("%lld",aux);
}
else{
if(s>p){
c=aux-5;
while(s!=p){
aux=c;
calcul();
if(s!=p)
c=aux-5;
}
printf("%lld%",aux);
}
else{
printf("%lld",aux);
}
}
}
}
}
return 0;
}