Cod sursa(job #2285861)
Utilizator | Data | 19 noiembrie 2018 13:45:47 | |
---|---|---|---|
Problema | Factorial | Scor | 10 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.5 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream f("fact.in");
ofstream g("fact.out");
int p,n,m5,k,cont;
int main()
{
f>>p;
if(p==0)
g<<"1";
else
{
n=p*5;
m5=25;
k=1;
cont=2;
while(m5<n)
{
while(m5*k<n)
{
n=n-5*(cont-1);
k++;
}
m5=m5*5;
cont++;
}
g<<n;
}
return 0;
}