Cod sursa(job #3141285)

Utilizator Pacurari_SofiaPacurari Sofia Pacurari_Sofia Data 13 iulie 2023 14:24:17
Problema Factorial Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.49 kb
#include <fstream>

using namespace std;

ifstream fin("fact.in");
ofstream fout("fact.out");

long zero(int x)
{
    long sum=0, c=5;
    while(x!=1)
    {
        sum+=x/c;
        x/=c;
    }
    return sum;
}

long cb(long st, long dr, long val)
{ long mij;
    while(st<dr)
    {
        mij=(st+dr)/2;
        if(zero(val)>p) st=mij+1;
        else dr=mij;
    }
    return mij;
}

int main()
{
    long n, p;
    fin>>p;
    fout<<cb(1, 1e17, p);
    return 0;
}