Cod sursa(job #639422)
Utilizator | Balasanu Andrei Nicolae andrei1291 | Data | 23 noiembrie 2011 10:45:26 |
---|---|---|---|
Problema | Factorial | Scor | 5 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.43 kb |
#include<fstream>
#include<iostream>
using namespace std;
ifstream fin("fact.in");
ofstream fout("fact.out");
int main()
{
long long p,n=0,k1,k2,z=25;
register long long i=0;
fin>>p;
if(p==0)
fout<<1;
n=p*5;
k1=n;
while(z<k1)
{
i++;
z=z*5;
k1=k1-i*5;
}
n=(p+1)*5;
k2=n;
z=25;
i=0;
while(z<k2)
{
i++;
z=z*5;
k2=k2-i*5;
}
if(k2<=k1)
fout<<-1;
else
fout<<k1;
return 0;
}