Cod sursa(job #2346265)

Utilizator AlexutAlex Calinescu Alexut Data 17 februarie 2019 14:34:03
Problema Factorial Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.51 kb

#include <fstream>

using namespace std;

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

int nrzerouri(int n)
{
    int nr=0;
    while(n>=5){
        nr+=n/5;
        n/=5;
    }
    return nr;
}

const int L=28;

int main()
{
    int n,r,pas;
    pas=1 << L;
    in>>n;
    r=0;
    while(pas!=0){
        if(nrzerouri(r+pas)<n){
            r+=pas;
        }
        pas/=2;
    }
    r++;
    if(nrzerouri(r)==n)
        out<<r;
    else
        out<<"-1";
    return 0;
}