Cod sursa(job #2078438)

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

int main()
{
ifstream fin("fact.in") ;
ofstream fout("fact.out");
  int P,pas=1,r,x;
  fin>>P;
  r=5*P;
  while(pas*5<r)
    pas*=5;
    x=pas;
  while(pas>5)
  {
      r-=(pas/5);
      x-=(pas/5);
      if(x==pas/5)
        pas/=5;
  }
  if(r) fout<<r;
  else fout<<"1";
    return 0;
}