Pagini recente » Cod sursa (job #1640968) | Cod sursa (job #993460) | Cod sursa (job #2236853) | Cod sursa (job #1290809) | Cod sursa (job #1750889)
#include <cstdio>
using namespace std;
int n;
int p[]={5, 25, 125, 625, 3125, 15625, 78125, 390625, 1953125, 9765625, 48828125};
int main()
{
freopen("fact.in", "r", stdin);
freopen("fact.out", "w", stdout);
scanf("%d", &n);
if(n==0) {printf("1");return 0;}
int st=1,dr=100000000;
while(1==1){
int mij=(st+dr)/2;
int j=0,legendre=0;
while(p[j]<=mij&&j<=10){
legendre=legendre+(mij/p[j]);
++j;
}
if(legendre==n){printf("%d",mij-mij%5);return 0;}
else if(legendre<n) st=mij+1;
else dr=mij-1;
}
return 0;
}