Cod sursa(job #1141489)
Utilizator | Data | 12 martie 2014 21:58:37 | |
---|---|---|---|
Problema | Factorial | Scor | 25 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.35 kb |
#include<fstream>
using namespace std;
unsigned long int P,N,aux;
unsigned long int z(unsigned long int x)
{unsigned long int s=0,p5=1;
while(p5<x)
{p5*=5;
s+=x/p5;
}
return s;
}
int main()
{ifstream f("fact.in");
ofstream g("fact.out");
f>>P;
if(P==0)
g<<1;
else
{while(z(N)<P)
N+=5;
if(z(N)>P)
g<<-1;
else
g<<N;
}
return 0;
}