Cod sursa(job #2074305)

Utilizator verde.cristian2005Verde Flaviu-Cristian verde.cristian2005 Data 24 noiembrie 2017 14:01:05
Problema Factorial Scor 90
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.55 kb
#include <fstream>
using namespace std;
ifstream in("fact.in");
ofstream out("fact.out");
unsigned long long p;
bool verif(unsigned long long n)
{
    unsigned long long cnt=0,cat=0;
    cat=n/5;
    cnt=cat;
    while(cat)
    {
     cat/=5;
     cnt+=cat;
    }
    if(cnt<p)
        return 0;
    return 1;
}
void cautbin()
{
    unsigned long long r=0,pas=1LL<<63;
    while(pas)
    {
        if(verif(r+pas)==0)
            r+=pas;
        pas/=2;
    }
    out<<r+1;
}
int main()
{
    in>>p;
    cautbin();
    return 0;
}