Pagini recente » Cod sursa (job #266480) | Profil andreea0146 | Cod sursa (job #767475) | Cod sursa (job #1441122) | Cod sursa (job #930336)
Cod sursa(job #930336)
#include<cstdio>
using namespace std;
int i, n, st, dr, mij, x;
int corect(int x){
int rez; rez=0;
while (x>=5) {rez+=x/5; x=x/5;}
if (rez>=n) return 0; else return 1;
}
int corectfix(int x){
int rez; rez=0;
while (x>=5) {rez+=x/5; x=x/5;}
if (rez==n) return true; else return false;
}
int main(){
freopen("fact.in","r",stdin);
freopen("fact.out","w",stdout);
scanf("%d", &n);
st=1; dr=10*10*10*10*10*10*10*10;
while (dr-st>=2) {
mij=(st+dr)/2;
x=corect(mij);
if (x==0) dr=mij; else st=mij;
}
if (corectfix(st)==true) printf("%d\n", st); else printf("%d\n", dr);
return 0;
}