Cod sursa(job #2217569)

Utilizator ce_pyCeppy Ceppilescu ce_py Data 30 iunie 2018 21:39:45
Problema Factorial Scor 5
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.51 kb
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("fact.in");
ofstream fout("fact.out");
int main()
{
    long long p, n, ok, k=2;
    fin>>p;
    n=p*5;
    ok=1;
    while(6*k-1<=p)
    {
        if(6*k-1==p)
        {
            fout<<-1;
            return 0;
        }
        k++;
    }
    if(p==0)
    {
        fout<<-1;
        return 0;
    }
    for(int x=25; x<=n; x*=5)
        for(int y=x; y<=n; y+=y)
        {
            n-=5;
        }
    fout<<n;
}