Cod sursa(job #986292)
Utilizator | Cella Florescu cella.florescu | Data | 18 august 2013 14:12:25 |
---|---|---|---|
Problema | Factorial | Scor | 0 |
Compilator | c | Status | done |
Runda | Arhiva de probleme | Marime | 0.59 kb |
#include <stdio.h>
#include <stdlib.h>
int main()
{
FILE *fin, *fout;
fin=fopen("factorial.in", "r");
fout=fopen("factorial.out", "w");
int p, cp;
long long n, cn;
fscanf(fin, "%d", &p);
n=0; cp=p;
while(p>0){
n+=5;
cn=n;
while(cn%5==0 && cn>0){
p--;
cn/=5;
}
}
if(cp==0){
fprintf(fout, "%d", 1);
}
else{
if(p==0){
fprintf(fout, "%d", n);
}
else{
fprintf(fout, "%d", -1);
}
}
fclose(fin);
fclose(fout);
return 0;
}