Cod sursa(job #2619588)

Utilizator florian_petrutCoaje Petrut florian_petrut Data 28 mai 2020 00:46:35
Problema Factorial Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.61 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,mij;
    f>>p;
    if(p==0)
        g<<1;
    else {  dr=10*p;
            while(st<=dr){
            mij=st+(dr-st)/2;
            if(zerouri(mij)<p)
                st=mij+1;
            else if(zerouri(mij)>p)
                    dr=mij-1;
                else {g<<mij/5*5;
                        return 0;}
            }
        g<<-1;}
    return 0;
}