Cod sursa(job #11375)

Utilizator sigridMaria Stanciu sigrid Data 31 ianuarie 2007 15:21:41
Problema Factorial Scor 50
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.59 kb
#pragma option -3 -a -Z -O2 -r
#include<fstream.h>
#include<math.h>
unsigned long i,pp,c;
int putere(unsigned long x,unsigned long &c)
{unsigned long xx;
 xx=x;
 while((xx>0)&&(xx!=5))
 {xx=xx/5;
  c++;
 }
 if(xx==5) return 1;
return 0;
}
int main()
{ifstream f("fact.in");
 ofstream g("fact.out");
 f>>pp;
 f.close();
 if(pp==0) {g<<1<<'\n';g.close();return 0;}
 i=5;
 pp--;
 while(pp)
  {i+=5;
   c=i/5;
   pp--;
   while(c%5==0)
    {pp--;
     c=c/5;
    }
  }
 if(pp==0){g<<i<<'\n';g.close();return 0;}
   else {g<<(-1)<<'\n';g.close();return 0;}
//return 0;
}