Cod sursa(job #2779746)

Utilizator Codrut198Codrut Dinca Codrut198 Data 4 octombrie 2021 20:40:49
Problema Factorial Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.43 kb
#include <fstream>
#include <iostream>
using namespace std;
ifstream f("fact.in");
ofstream g("fact.out");
int main()
{
    long long x,s=0,i=0,j,s1=0;
    cin>>x;
    if(x==0)
        cout<<1;
    else
        {
            s=x*5-5*((x-5)/5);
            for(j=5;j<=500000000;j*=5)
                s1+=s/j;

            if(x==s1)
                cout<<s;
            else
                cout<<"-1 ";
        }
}