Cod sursa(job #764118)
Utilizator | Data | 4 iulie 2012 09:41:55 | |
---|---|---|---|
Problema | Factorial | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.35 kb |
#include<fstream>
using namespace std;
int p,n,k,x,i;
ifstream f("fact.in");
ofstream g("fact.out");
int main ()
{
f>>p;
if(!p)
n=1;
else
n=0;
do
{
i=0;
k=1;
x=0;
while(x-i+1<=p)
{
k=k*5;
x=5*x+1;
i++;
}
n=n+k/5;
p=p-x/5;
}while(p>0);
if(!p)
g<<n;
else
g<<"-1";
return 0;
}