Cod sursa(job #1390562)
Utilizator | Data | 17 martie 2015 09:37:02 | |
---|---|---|---|
Problema | Factorial | Scor | 80 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.39 kb |
#include <iostream>
#include <fstream>
using namespace std;
int main()
{ifstream fin ("fact.in");
ofstream fout ("fact.out");
int P,a,b,j,i;
fin>>P;
a=5*P;
b=P;
if (P==0)
fout<< 1;
else
{for (i=5;i<=b;i+=5)
{j=i;
while (j%5==0)
{j=j/5;
a-=5;
b--;
}
}
fout<<a;
}
fin.close();
fout.close();
return 0;
}