Cod sursa(job #2460662)

Utilizator teisanumihai84Mihai Teisanu teisanumihai84 Data 24 septembrie 2019 09:13:25
Problema Factorial Scor 15
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.44 kb
#include <fstream>
using namespace std;
int p, st, dr, put, s;
int main ()
{
   ifstream fin ("fact.in");
   ofstream fout ("fact.out");
   fin>>p;
   st=1;
   dr=1000000;
   while (st<=dr)
   {
       int mid=(st+dr)/2;
       s=0;
       put=5;
       while (mid/put!=0)
       {
           s+=mid/put;
           put*=5;
       }
       if (s>=p)
            dr=mid-1;
       else
            st=mid+1;
   }
   fout<<st;
}