Cod sursa(job #2078458)

Utilizator CryshanaGanea Carina Cryshana Data 29 noiembrie 2017 16:43:53
Problema Factorial Scor 5
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.4 kb
#include <iostream>
#include <fstream>
#include <algorithm>
using namespace std;

int nr_0 (int x)
{
    int a=5,p=0;
    while(a<=x)
    {
        p+=x/a;
        a*=5;
    }
    return p;
}


int main()
{
ifstream fin("fact.in") ;
ofstream fout("fact.out");
  int P,r=0;
  long long pas=1<<31;
  fin>>P;
  while(pas!=0)
  {
      if(nr_0(r+pas)<P)
        r+=pas;
      pas/=2;
  }
  fout<<r+1;
    return 0;
}