Cod sursa(job #2233249)

Utilizator stefanboiuBoiu Stefan stefanboiu Data 22 august 2018 18:07:27
Problema Factorial Scor 25
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.39 kb
#include <iostream>
#include <fstream>
using namespace std;

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