Cod sursa(job #2364978)

Utilizator RazvanucuPopan Razvan Calin Razvanucu Data 4 martie 2019 11:37:54
Problema Factorial Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.46 kb
#include <iostream>
#include <fstream>
#define NMax 1000000
using namespace std;
ifstream f("factorila.in");
ofstream g("factorila.out");
long long m,s,d,i,x;
long long a[NMax];
int main()
{
    f>>x;
    for(i=1; i<=x*5; i++)
        a[i]=i/5;

    s=1,d=x*5;
    while (s<=d)
    {
        m=s+(d-s)/2;
        if (a[m]<=x)
            s=m+1;
        else
            d=m-1;
    }
    m=s+(d-s)/2;
    m--;
      g<<m;

    return 0;
}