Pagini recente » Cod sursa (job #533044) | Cod sursa (job #2393091) | Cod sursa (job #1305482) | Cod sursa (job #180167) | Cod sursa (job #2073651)
#include <iostream>
#include <stdio.h>
#include <algorithm>
using namespace std;
int v[801];
int fact(int x){
int suma=0,p=5;
while(x/p>0){
suma+=x/p;
p*=5;
}
return suma;
}
int main(){
freopen("fact.in","r",stdin);
freopen("fact.out","w",stdout);
int putere,s,p;
scanf("%d",&p);
putere=1<<30;
s=0;
while(putere>0){
if(fact(s+putere)<=p-1)
s+=putere;
putere/=2;
}
if(fact(s+1)==p)
printf("%d",s+1);
else
printf("-1");
return 0;
}