Cod sursa(job #1509608)
Utilizator | Data | 24 octombrie 2015 09:19:01 | |
---|---|---|---|
Problema | Factorial | Scor | 55 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.44 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("fact.in");
ofstream fout("fact.out");
int main()
{
int P, x, y;
fin>>P;
x=0;
if(P==0) 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) fout<<-1;
else fout<<x;
}
return 0;
}