Cod sursa(job #1800532)

Utilizator RazvanGutaGuta Razvan Alexandru RazvanGuta Data 7 noiembrie 2016 21:07:04
Problema Factorial Scor 15
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.52 kb
#include<fstream>
using namespace std;
ifstream f("fact.in");
ofstream g("fact.out");
long long p,st,dr,mij;
int nrzero (int x)
{
    int k=0;
    for(int i=1;i<=x;i++)
    {
      int t=i;
        while(t%5==0)
            {
                k++;
                t=t/5;
            }

    }
    return k;
}
int main ()
{
    f>>p;
    st=1;
    dr=5*p;
    while(st<=dr)
    {
        mij=st+(dr-st)/2;
        if(nrzero(mij)>=p)
        dr=mij-1;
        else
        st=mij+1;
    }
    g<<st;
}