Cod sursa(job #2416745)

Utilizator vlad082002Ciocoiu Vlad vlad082002 Data 27 aprilie 2019 23:56:52
Problema Factorial Scor 40
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.54 kb
#include <iostream>
#include <fstream>
using namespace std;

int p, zero = 0;

int main() {
    ifstream f("fact.in");
    ofstream g("fact.out");
    f >> p;
    if(p == 0)
        g << 1;
    else {
        int n = 0;
        while(zero < p) {
            n += 5;
            int c = n;
            while(c % 5 == 0) {
                c /= 5;
                zero++;
            }
        }
        if(zero == p)
            g << n;
        else
            g << -1;
    }

    f.close();
    g.close();
    return 0;
}