Pagini recente » Schimbarea compilatoarelor Borland la OJI | Cod sursa (job #821852) | Cod sursa (job #1113997) | Cod sursa (job #2665557) | Cod sursa (job #1730074)
#include <cstdio>
using namespace std;
inline int fct(int n)
{
int x=0;
for(register int i=5;i<=n;i*=5)
x+=n/i;
return x;
}
int main()
{
freopen("fact.in", "r", stdin);
freopen("fact.out", "w", stdout);
int p;
scanf("%d", &p);
if(p==0)
{
printf("1\n");
return 0;
}
int stg=1;
int dr=100000000;
while(stg<=dr)
{
int med=stg+(dr-stg)/2;
if(fct(med)==p)
break;
if(fct(med)>p)
dr=med-1;
else
stg=med+1;
}
if(!(stg<=dr))
{
printf("-1\n");
return 0;
}
int med=stg+(dr-stg)/2;
if(fct(med)==p&&med%5!=0)
while(med%5)
med--;
printf("%d\n", med);
return 0;
}