Cod sursa(job #2787926)

Utilizator Luca_Miscocilucainfoarena Luca_Miscoci Data 24 octombrie 2021 13:06:29
Problema Patrate2 Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.65 kb
#include <fstream>

#define NMAX 10000
using namespace std;

int huge[NMAX + 1];

int multiply (int nrcif, int x){
  int t = 0, i;
  for (i = 0; i < nrcif || t != 0; i++){
    t += huge[i] * x;
    huge[i] = t % 10;
    t /= 10;
  }
  if (nrcif < i)
    nrcif = i;
  return nrcif;
}

int main(){

  ifstream fin ("patrate2.in");
  ofstream fout ("patrate2.out");

  int n;
  int nrpos = 1;
  huge[0] = 1;
  fin >> n;

  for (int i = 2; i <= n; i++){
    nrpos = multiply(nrpos, i);
  }

  for (int i = 1; i <= n * n; i++)
    nrpos = multiply(nrpos, 2);

  for (int i = nrpos - 1; i >= 0; i--)
    fout << huge[i];
  return 0;
}