Cod sursa(job #2343789)

Utilizator nunucotropitoruDarabant Alex Dan nunucotropitoru Data 14 februarie 2019 12:40:30
Problema A+B Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.64 kb
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("fact.in");
ofstream fout("fact.out");
int stanga,dreapta,x,p,n,mijloc;
int main()
{
    fin>>p;
    if (p==0)
    {
        fout<<1;
        return 0;
    }
    stanga=1;
    dreapta=800000000;
    while (stanga<=dreapta && n!=p)
    {
        n=0;
        mijloc=(st+dr)/2;
        x=m/5;
        while(x)
        {
            n+=x;
            x/=5;
        }
        if (n>p)
            dreapta=mijloc-1;
        else
            stanga=mijloc+1;
    }
    if (stanga<=dreapta)
        fout<<mijloc-mijloc%5;
    else
        fout<<-1;
}