Cod sursa(job #138691)
| Utilizator | Data | 19 februarie 2008 00:19:15 | |
|---|---|---|---|
| Problema | Factorial | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.48 kb |
#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);
//cin>>P;
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) {P--;
N2=N2/5;}
N=N+5;}}
if (P<0) printf ("%d",truth);
if (P==0 && N!=0) printf ("%ld",N);
return 0;}