Cod sursa(job #170436)

Utilizator fight4kissesSosu Cristian fight4kisses Data 2 aprilie 2008 19:15:40
Problema Factorial Scor 65
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.47 kb
#include<fstream>
using namespace std;
fstream f,g;
int i,n,k,x,c;
int main()
{
f.open("fact.in",ios::in);
f>>k;
f.close();
g.open("fact.out",ios::out);
i=-1;
if(k==0) g<<1;
else 
  {
  x=0;
  if (k<=5) g<<k*5;
  else
    {
    for(i=6;i<=k;i=i+6)
      {
      x=x+25;
      n=x;
      c=0;
      while(n%5==0)
        {
        n=n/5;
        c++;
        }
      i=i+c-2;
      }
    }
  }
if(i==k) g<<x;
else
  {
  i=i-6;
  x=x+(k-i)*5;
  g<<x;
  }
g.close();
return 0;
}