Pagini recente » Cod sursa (job #1434698) | Cod sursa (job #2003234) | Cod sursa (job #2133161) | Cod sursa (job #48883) | Cod sursa (job #1326921)
#include <fstream>
#include <iostream>
using namespace std;
int main()
{
long long p,n,i,aux,cnt,x;
ifstream fin("fact.in");
fin>>p;
i=1;
n=1;
aux=p;
cnt=0;
while(aux>0)
{
++i;
n*=i;
if(n%10==0) {aux--;x=n/10;}
while(n%10==0)
{
cnt++;
n/=10;
}
n=x;
}
if(cnt-p==0)
p*=5;
if(cnt-p==1)
p=(p-1)*5;
if(cnt-p==2)
p=(p-2)*5;
if(cnt-p==3)
p=(p-3)*5;
if(cnt-p==4)
p=(p-4)*5;
if(cnt-p==5)
p=(p-5)*5;
if(cnt-p==6)
p=(p-6)*5;
if(cnt-p==7)
p=(p-7)*5;
ofstream fout("fact.out");
fout<<p;
fout.close();
return 0;
}