Cod sursa(job #2619580)

Utilizator florian_petrutCoaje Petrut florian_petrut Data 28 mai 2020 00:23:07
Problema Factorial Scor 45
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.49 kb
#include <iostream>
#include <fstream>
using namespace std;

ifstream f("fact.in");
ofstream g("fact.out");

int zerouri(int n){
    int s=0;
    while(n/5)
        {s+=n/5;
        n/=5;}
    return s;
}
int main()
{
    int p,st=1,dr=100000000,mij;
    f>>p;
    while(st<=dr){
        mij=(st+dr)/2;
        if(zerouri(mij)<p)
                st=mij+1;
        else dr=mij-1;

    }
    if(zerouri(mij)==p)
            g<<mij;
        else g<<-1;

    return 0;
}