Pagini recente » Cod sursa (job #650510) | Cod sursa (job #2636774) | Cod sursa (job #578402) | Cod sursa (job #2677785) | Cod sursa (job #217590)
Cod sursa(job #217590)
#include<stdio.h>
//using namespace std;
int factorial(int zero, int &x,int n) {
//long x=j;
//for (long i=n-1 ; i<=n ; i++) {
x=x*n;
while (x%10==0 && x/10!=0) {
zero++;
x=x/10;
}
x=x%10;
//}
return zero;
}
int main() {
freopen("fact.in","r",stdin);
freopen("fact.out","w",stdout);
int p,n=1,zero=0,x=1;
scanf("%d\n", &p);
while (zero<p) {
n++;
zero=factorial(zero,x,n);
}
if (zero>p) printf("-1\n");
else printf("%d\n",n);
return 0;
}