Cod sursa(job #2617690)

Utilizator pascustefanPascu Stefan Liviu pascustefan Data 22 mai 2020 17:06:55
Problema Factorial Scor 25
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.45 kb
#include <iostream>
#include <fstream>

using namespace std;
ifstream f("fact.in");
ofstream g("fact.out");
int n, s, cpy;

int main()
{
    f>>n;
    if(n == 0)
        g<<1;
    else {
        s = 5;
        n--;
        while(n > 0) {
            s = s + 5;
            cpy = s;
            while(cpy % 5 == 0) {
                cpy = cpy / 5;
                n--;
            }
        }
        g<<s;
    }
    return 0;
}