Cod sursa(job #2315437)
| Utilizator | Data | 9 ianuarie 2019 22:57:43 | |
|---|---|---|---|
| Problema | Factorial | Scor | 15 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.51 kb |
#include <fstream>
using namespace std;
int main() {
ifstream fin("fact.in");
ofstream fout("fact.out");
long long int p,i,n,j,y;
fin>>p;
n=0;
y=0;
i=0;
if (p>390625)
{
n=78125;
i=n;
y=390625;
}
while (y<p)
{
i+=5;
j=i;
n=j;
while (j%5==0)
{
y++;
j/=5;
}
}
if (y==p)
{
fout<<n;
}
else if (p==0) { fout<<"1";}
else fout<<"-1";
return 0;
}
