Cod sursa(job #2075229)

Utilizator AndreiVisoiuAndrei Visoiu AndreiVisoiu Data 25 noiembrie 2017 12:01:44
Problema Factorial Scor 30
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.41 kb
#include <fstream>

using namespace std;

ifstream in("fact.in");
ofstream out("fact.out");

int p, x, z, n = 5, n2;
bool ok = true;
int main()
{
    in >> p;
    if(p == 0) { out << 1; return 0; }
    while(z < p) {
        n2 = n;
        while(n2%5 == 0) {
            n2 = n2/5;
            z++;
        }
        n += 5;
    }

    if(z == p) out << n-5;
    else out << 0;
    return 0;
}