Cod sursa(job #581267)

Utilizator frumushelRadu Lucian Andrei frumushel Data 13 aprilie 2011 22:45:10
Problema Factorial Scor 20
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.5 kb
#include<iostream>
#include<fstream>
using namespace std;
int nr_de5(long x)
{
 int nr=0;
 while(x%5==0)
 {
  nr++;
  x/=5;
 }
return nr;
}
int nr_de2(long x)
{
 int nr=0;
 while(x%2==0)
 {
   nr++;
   x/=2;
 }
return nr;
}
int main()
{
  int nr2=0,nr5=0;
  long p,t=1,y;
  ifstream f("fact.in");
  ofstream g("fact.out");
  f>>p;
  while(nr5<=p-1)
  {
   y=t;
   while(y%5==0 && nr5<=p-1)
   {
    nr5++;
    y/=5;
   } 
  t++;
  }
  g<<t-1;
  return 0;
 
}