Cod sursa(job #1944024)

Utilizator alexkosaAlex Kosa alexkosa Data 28 martie 2017 22:06:50
Problema Factorial Scor 30
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.48 kb
#include <fstream>
using namespace std;
ifstream fin("fact.in");
ofstream fout("fact.out");
int main()
{int p,n,i,c=0,j,o=0;
fin>>p;
if(p==0)
    fout<<"1";
else if(p==1)
    fout<<"5";
else if(p==2)
    fout<<"10";
else{
    n=5*p;

    for(i=5;i<=5*p;i=i+5){
            c=0;
            j=i;
        while(j%5==0){
            c++;
            o++;
            j=j/5;}

        n=n-5*(c-1);
        if(o==p)
            break;

}
fout<<n;
}

return 0;}