Cod sursa(job #1833680)

Utilizator sabinantonSabin Anton sabinanton Data 22 decembrie 2016 21:54:36
Problema Factorial Scor 5
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.54 kb
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("fact.in");
ofstream fout("fact.out");
int nrZero( int nr ) {
    int k;

    k = 0;
    while ( nr ) {
        nr /= 5;
        k += nr;
    }

    return k;
}
int main()
{
    long long p,n=0,i=0,c;
    fin>>p;
    int cp=p;
    while(cp%5==0)
    {
        cp/=5;
        n++;
    }
    //cout<<nrZero(p)<<" ";
    fout<<5*p-(nrZero(p)-n)*5;
    while(p>0)
    {
        if(p>0)n+=5*(p);
        p-=n;
    }
    //cout<<n;


    return 0;
}