Cod sursa(job #442694)

Utilizator MurphYZoRMarius Eu de la 9B-re MurphYZoR Data 14 aprilie 2010 23:15:09
Problema Factorial Scor 10
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.33 kb
#include<iostream>
#include<fstream>
using namespace std;
ifstream f("fact.in");
ofstream g("fact.out");
int main()
{ int nf,t=5,y=0;
  long p;
  f>>p;
  nf=p*t;
  if(nf==0)
  g<<1;
  else
  {
  while(t<=nf)
  {
   t=t*5;
   y++;
   if(t<=nf)
   nf-=5*y;
  }
  g<<nf;
  }
  f.close();
  g.close();
  return 0;
}