Cod sursa(job #2077658)

Utilizator ioana_99Ioana Marin ioana_99 Data 28 noiembrie 2017 13:37:16
Problema Factorial Scor 90
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.51 kb
#include <iostream>
#include <fstream>
using namespace std;

ifstream f("fact.in");
ofstream g("fact.out");
long p,pas,r,l;
int zero(long n)
{
    int nrz=0;
    while(n>=5)
    {
        nrz+=(n/5);
        n/=5;
    }
    return nrz;
}
int caut_bin(long x)
{
    pas=1<<l;
    r=0;
    while(pas!=0)
    {
        if(zero(r+pas)<x)
        {
            r+=pas;
        }
        pas/=2;
    }
    r++;
    return r;
}
int main()
{
   f>>p;
   l=30;
    g<<caut_bin(p);
    return 0;
}