Cod sursa(job #3350249)

Utilizator iustinG1314Gorgan Iustin iustinG1314 Data 6 aprilie 2026 17:18:59
Problema Factorial Scor 80
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.65 kb
#include <fstream>
using namespace std;
ifstream cin("fact.in");
ofstream cout("fact.out");
int main()
{
    int n,s=0,x=0;
    cin>>n;
    if(n==0)
    {
        cout<<1;
    }
    else
    {
        int ok=0;
        while(x<n)
        {
            s+=5;
            int cs=s;
            int l=0;
            while(cs%5==0)
            {
                l++;
                cs/=5;
            }
            x+=l;
            if(x==n)
            {
                ok=1;
                cout<<s;
                break;
            }
        }
        if(ok==0)
        {
            cout<<-1;
        }
    }
    return 0;
}