Cod sursa(job #270487)

Utilizator MihalutzzzMihalcut Cristian Mihalutzzz Data 4 martie 2009 07:56:13
Problema Factorial Scor 75
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.35 kb

#include<fstream.h>

ifstream g("fact.in");
ofstream h("fact.out");

int main()
{
 int p,i,c,k,n;
 g>>p;
 g.close();
 if(p==0) h<<1;
   else
 {for(i=1;p>0;i++)
  {c=1;
   k=i;
   while(k!=0)
    {if(k%5==0) {c++; k/=5;}
      else break;
    }
   p-=c;
  }

 if (p==0) {n=(--i)*5; h<<n;}
    else h<<-1;
}
 h.close();
 return 0;
}