Cod sursa(job #1397551)
Utilizator | Data | 23 martie 2015 16:38:27 | |
---|---|---|---|
Problema | Factorial | Scor | 20 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.5 kb |
#include <iostream>
#include <fstream>
using namespace std;
long j,i,x,p,nr=0,n;
int main()
{
ifstream f("fact.in");
ofstream g("fact.out");
f>>p;
if (p==0) {g<<1;return 0;}
else
for (i=p*4;i<=p*5;i++)
{
nr=0;
for (j=1;j<=i;j++)
{
x=j;
while (x%5==0)
{
nr++;
x=x/5;
}
}
if (nr==p) {g<<i;return 0;}
}
g<<-1;
return 0;
}