Cod sursa(job #1340712)
| Utilizator | Data | 11 februarie 2015 23:26:52 | |
|---|---|---|---|
| Problema | Factorial | Scor | 40 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.58 kb |
#include <iostream>
#include <fstream>
#include <math.h>
using namespace std;
int main()
{int p,n,k=0,c=0,ok,q=0,x,i;
ifstream f("fact.in");
ofstream g("fact.out");
f>>p;
if(p==0)
g<<"1";
else
{
for(i=5; k<=p && q==0; i+=5)
{x=i;ok=0;
while(x%5==0)
{x/=5;
k++;
if(ok==1)
c++;
ok=1;
}
if(k==p)
{q=1;
g<<5*(p-c);
}
if(k>p)
{q=1;
g<<"-1";
}
}
}
return 0;
}
