Cod sursa(job #883785)

Utilizator StefansebiStefan Sebastian Stefansebi Data 20 februarie 2013 13:06:08
Problema Factorial Scor 40
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.46 kb
#include<fstream>
using namespace std;
ifstream fin("fact.in");
ofstream fout("fact.out");
int i, p, cont5, y;
int main() {
    fin >> p;
    cont5 = 0; i = 0;
    while (cont5 < p) {
        i = i + 5;
        y = i;
        while (y % 5 == 0) {
            y = y / 5;
            cont5++;
        }
    }
    if (cont5 > p)
        fout << -1;
    else {
        if (p == 1)
            fout << 0;
        else
            fout << i;
    }
}