Cod sursa(job #2764680)

Utilizator ionutpop118Pop Ioan Cristian ionutpop118 Data 22 iulie 2021 10:27:54
Problema Patrate2 Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 1.37 kb
#include <fstream>
#include <algorithm>
#include <math.h>
#include <string.h>

using namespace std;

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

class HugeN {
private:
    int x[10005];
public:
    HugeN() {
        memset((*this).x, 0, sizeof(*this));
        (*this).x[0] = 1;
    }
    HugeN(int n) {
        memset((*this).x, 0, sizeof(*this));
        do {
            (*this).x[++(*this).x[0]] = n % 10;
            n = n / 10;
        } while (n != 0);
    }

    HugeN operator * (int n) {
        HugeN c;
        int i;
        c.x[0] = (*this).x[0];
        for(i = 1; i <= (*this).x[0]; ++i)
        {
            c.x[i] = (*this).x[i] * n;
        }

        for(i = 1; i <= (*this).x[0]; ++i)
        {
            c.x[i + 1] += c.x[i]/10;
            c.x[i] = c.x[i]%10;
        }

        while (c.x[c.x[0] + 1] != 0)
        {
            ++c.x[0];
            c.x[c.x[0] + 1] += c.x[c.x[0]] / 10;
            c.x[c.x[0]] %= 10;
        }

        return c;
    }

    void print() {
        for (int i = (*this).x[0]; i > 0; --i) {
            fout << (*this).x[i];
        }
        fout << endl;
    }
};

int main()
{
    int N, i;
    HugeN rez(1);
    fin >> N;

    for(i=1; i<=N;i++)
        rez = rez * i;
    for(i=1; i<=N*N; i++)
        rez = rez * 2;

    rez.print();

    return 0;
}