Cod sursa(job #3350248)

Utilizator iustinG1314Gorgan Iustin iustinG1314 Data 6 aprilie 2026 17:18:10
Problema Factorial Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.66 kb
#include <iostream>
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;
}