Cod sursa(job #2423344)

Utilizator Gabi_LazaLaza Gabriel Gabi_Laza Data 21 mai 2019 09:35:38
Problema Factorial Scor 25
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.52 kb
#include <fstream>
#define ever ;;
using namespace std;
ifstream in("fact.in");
ofstream out("fact.out");

unsigned long long x, y, rez;
int p;
int main() {
    x = 5;
    bool ik = false;
    in >> p;
    int nr = 0;
    for(ever) {
        if(p == 0)
            break;
        y = x;
        while(y%5 == 0) {
            nr++;
            y /= 5;
        }
        if(nr == p)
            break;
        x += 5;
    }
    if(p == 0)
        out << 1;
    else
        out << x;

    in.close();
    out.close();
    return 0;
}