Cod sursa(job #2609165)

Utilizator dumitrustefania1DUMITRU STEFANIA dumitrustefania1 Data 2 mai 2020 11:44:17
Problema Factorial Scor 10
Compilator cpp-64 Status done
Runda igorj_mentorat1 Marime 0.75 kb

#include <bits/stdc++.h>

using namespace std;
ifstream f("fact.in");
ofstream g("fact.out");
long long poww,x,p,minn,adun,ok;
int main()
{
    f>>p;
    if(p==0)
    {
        g<<1;
        return 0;
    }
    poww=5;
    adun=0;
    x=0;
    ok=1;
    while(p>=poww&&ok)
    {
        if(p>=poww+adun&&p<=poww+adun+x)
            ok=0;
        x++;
        adun+=x;
        poww*=5;
    }
    if(!ok)
    {g<<-1;
        return 0;
    }



    x=p*5;
    poww=25;
    minn=1;
    while(poww<x)
    {
        x-=minn*5;
        poww*=5;
        minn++;
    }

    g<<x;
    return 0;
}
/*
5
10
15
20
25 *2
30 7
35 8
40
45
50
55
60
65
70
75
80
85
90
95 20
100
105
110
115 24
125 27




*/