Cod sursa(job #2609264)

Utilizator dumitrustefania1DUMITRU STEFANIA dumitrustefania1 Data 2 mai 2020 13:04:13
Problema Factorial Scor 25
Compilator cpp-64 Status done
Runda igorj_mentorat1 Marime 0.6 kb

#include <bits/stdc++.h>
#define pb push_back
using namespace std;
ifstream f("fact.in");
ofstream g("fact.out");
int p,poww,i,x,ok,s,v[15];
int main()
{
    f>>p;
    poww=1;
    for(i=1; i<=12; i++)
    {
        poww*=5;
        v[i]=poww;

    }
    x=p*5;
    ok=1;
    while(ok)
    {
        s=0;
        for(i=1; i<=12&&v[i]<=x; i++)
            s+=x/v[i];
        if(s==p)
        {
            g<<x;
            ok=0;
        }
        else if(s<p)
        {
            g<<-1;
            ok=0;
        }
        else

            x-=5;

    }

    return 0;
}