Cod sursa(job #1937916)
| Utilizator | Data | 24 martie 2017 13:32:34 | |
|---|---|---|---|
| Problema | Factorial | Scor | 50 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.45 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("fact.in");
ofstream fout("fact.out");
int main()
{
int i,p,x;
fin>>p;
if(p==0)fout<<1;
else
{
for(i=5;p>0;i+=5)
{
x=i;
while(x%5==0)
{
p--;
x/=5;
}
}
i-=5;
if(p==0)fout<<i;
else fout<<-1;
}
return 0;
}
