Cod sursa(job #133546)

Utilizator conttPop Mircea contt Data 8 februarie 2008 21:54:07
Problema Factorial Scor 90
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.61 kb
#include <fstream>
#include <iostream>
#include <math.h>

using namespace std;

long divizori(long &x)
{
     long putere=0,cinci=0;
     while (cinci*5+1<=x){cinci=cinci*5+1; putere=putere+1;}

     x=x-cinci;
    
     return (long)ceil(pow(5,putere));
     }
     
int main()
{
    long p,n;
    ifstream f("fact.in");
    f>>p;
    f.close();
    n=0;
long adun;
if (p==0) n=1;
else if (p==1) n=5;
else
while (p>0)
 {adun=divizori(p);
 //cout<<endl<<"adun="<<adun;
  n=n+adun;
}        
            
       

ofstream g("fact.out");
g<<n;
g.close();
      return 0;
}