Cod sursa(job #2285857)

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