Cod sursa(job #287494)

Utilizator mihaionlyMihai Jiplea mihaionly Data 24 martie 2009 21:56:06
Problema Factorial Scor 25
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.41 kb
#include <fstream>
using namespace std;
typedef long long tip;
tip p,fn,i;
ifstream f("fact.in");
ofstream g("fact.out");
tip stoarce(tip x)
 {
 long z=0;
 while(x%5==0)
  {
  x/=5;
  z++;
  }
 return z;
 }
int main()
 {
 f>>p;
 if(p==0)
  {
  g<<"1";
  return 0;
  }
 for(i=5;fn<p;i+=5)
  {
  fn+=stoarce(i);
  }
 i-=5;
 if(fn==p)
  g<<i;
 else if(fn>p)
  g<<"-1";
 return 0;         
 }