Cod sursa(job #2075235)

Utilizator AndreiVisoiuAndrei Visoiu AndreiVisoiu Data 25 noiembrie 2017 12:04:04
Problema Factorial Scor 55
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.47 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;
        if(n2%25 == 0) {
            while(n2%5 == 0) {
                n2 = n2/5;
                z++;
            }
        } else z++;
        n += 5;
    }

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