Cod sursa(job #1106079)
Utilizator | Data | 12 februarie 2014 14:36:26 | |
---|---|---|---|
Problema | Factorial | Scor | 40 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.43 kb |
#include <cstdio>
using namespace std;
FILE *f=fopen("fact.in","r");
FILE *g=fopen("fact.out","w");
int main()
{int p,n,x;
fscanf(f,"%d",&p);
if (p==0) fprintf(g,"1\n");
else {n=0;
while (p!=0) {n+=5;
p--;
x=n/5;
while (x%5==0) {p--;x/=5;}
}
fprintf(g,"%d\n",n);
}
return 0;
}