Pagini recente » Cod sursa (job #890100) | Cod sursa (job #2708589) | Cod sursa (job #403264) | Cod sursa (job #178378) | Cod sursa (job #138695)
Cod sursa(job #138695)
#include<iostream.h>
#include<stdio.h>
int main ()
{long long N2,c,c2;
long int P,N=0;
int truth=-1,truth2=1;
freopen ("fact.in", "rt" ,stdin);
freopen ("fact.out","wt" ,stdout);
scanf ("%ld",&P);
if (P==0) printf ("%d",truth2);
else {for (N=25,c2=1,c=6;P>=c;N=N+25,P=P-c,c2++) if (c2==5) {c2=0; c++;}
while (P>0) {N2=N;
while (N2%5==0) {P--;
N2=N2/5;}
N=N+5;}}
if (P<0) printf ("%d",truth);
if (P==0 && N!=0) printf ("%ld",N);
return 0;}