Cod sursa(job #40234)

Utilizator TylorDurdenMuresan Ionut TylorDurden Data 27 martie 2007 12:12:24
Problema Factorial Scor 10
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.53 kb
#include <fstream>
#include <math.h>
using namespace std;

ifstream in("fact.in");
ofstream out("fact.out");
int n, p, s;

main()
{
      int k=1, P=1;
      in>>p;
      
      while(s!=p)
      {
                 s=0;
                 n+=5;
                 
                 while( P*5<=n )
                 {
                        P*=5;
                        k++;
                 }
                 
                 for(int i=1;i<=k;i++)
                 s+=n / (pow(5, i));
      }
      
      out<<n;
}