Cod sursa(job #1509600)
| Utilizator | Data | 24 octombrie 2015 09:06:51 | |
|---|---|---|---|
| Problema | Factorial | Scor | 55 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.51 kb |
#include <iostream>
#include <fstream>
using namespace std;
FILE *fin=fopen("fact.in", "r");
FILE *fout=fopen("fact.out", "w");
int main()
{
int P, x, y;
fscanf(fin, "%d", &P);
x=0;
if(P==0) fprintf(fout, "1");
else{
while(P>0)
{
x=x+5;
y=x;
P--;
y=y/5;
while(y%5==0)
{
y=y/5;
P--;
}
}
if(P<0) fprintf(fout, "%d", -1);
else fprintf(fout, "%d", x);
}
return 0;
}
