Cod sursa(job #2779529)

Utilizator puica2018Puica Andrei puica2018 Data 4 octombrie 2021 09:19:15
Problema Patrate2 Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.76 kb
#include <bits/stdc++.h>

using namespace std;

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

typedef int Huge[1000005];

void AtribValue(Huge H, unsigned long X) {
  H[0] = 0;
  while (X) {
      ++H[0];
      H[H[0]] = X % 10;
      X /= 10;
  }
}

void Mult(Huge H, unsigned long X)
{ int i;
  unsigned long T=0;

  for (i=1;i<=H[0];i++)
    { H[i]=H[i]*X+T;
      T=H[i]/10;
      H[i]=H[i]%10;
    }
  while (T)
    { H[++H[0]]=T%10;
      T/=10;
    }
}

int n;
Huge res;

int main()
{
    fin>>n;
    AtribValue(res,1);
    for(int i=1; i<=n; i++)
        Mult(res,i);
    for(int i=1; i<=n*n; i++)
        Mult(res,2);
    for(int i=res[0]; i>0; i--)
        fout<<res[i];
    fout<<"\n";
    return 0;
}