Cod sursa(job #416811)
Utilizator | Moraru Valentina valentina506 | Data | 13 martie 2010 16:07:49 |
---|---|---|---|
Problema | Factorial | Scor | 25 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.38 kb |
#include<fstream>
#define maxim 100000000
using namespace std;
long p,d5,n;
int main()
{
ifstream f("fact.in");
ofstream g("fact.out");
f>>p;
if(p==0)
g<<1;
else
if(p<0||p>maxim)
g<<-1;
else
{
n=2;
while(d5<p)
{ long m=n;
if(m%5==0)
while(m&&m%5==0)
{
m/=5;
d5++;
}
n++;
}
g<<n-1;
}
return 0;
}