Cod sursa(job #778617)

Utilizator dan89Stan Alexandru dan89 Data 15 august 2012 11:14:09
Problema Factorial Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.36 kb
#include<fstream>
using namespace std;
ifstream in("factorial.in");
ofstream out("factorial.out");

int p,n = 1,d,c,x;

int main(){
  in>>p;
  while(p > 0)
  { x=n;
    while(x % 2 == 0)
      d++,x/=2;
    while(x % 5 == 0)
      c++,x/=5;
    while(d>0 && c>0){
      p--;
      d--;
      c--;
    }
    n++;

  }
  out<<n-1;
  in.close();
  out.close();
  return 0;
}