Cod sursa(job #1596642)

Utilizator ArceyGeorge Cioroiu Arcey Data 11 februarie 2016 11:22:12
Problema Patrate2 Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 2.32 kb
#include <cstdio>
#include <iostream>
#include <set>
#include <climits>
#include <map>
#include <algorithm>
#include <list>
#include <vector>
#include <utility>
#include <cstdlib>
#include <iomanip>
#include <cstring>
#include <string>

using namespace std;

class BigInteger {
public:
    //  CONSTANTE SPECIFICE
    static const int base = 10000;
    static const int logBase = 4;

    //  NUMAR MARE
    int digit[1000];
    int numberOfDigits;

    //  CONSTRUCTORI
    BigInteger() {
        this->numberOfDigits = 0;
        this->digit[0] = 0;
    }

    BigInteger(int n) {
        this->numberOfDigits = 0;
        while (n > 0) {
            this->digit[this->numberOfDigits++] = n % base;
            n /= base;
        }
    }

    //  OPERATORI

    //  ATRIBUIRI
    BigInteger operator = (BigInteger a) {
        this->numberOfDigits = a.numberOfDigits;
        memcpy(this->digit, a.digit, this->numberOfDigits * sizeof(int));
    }

    //  INMULTIRE
    friend BigInteger operator * (BigInteger a, int b) {
        int carry = 0;
        BigInteger ans;

        for (int i = 0; i < a.numberOfDigits; i++) {
            carry += a.digit[i] * b;
            ans.digit[i] = carry % base;
            carry /= base;
        }

        ans.numberOfDigits = a.numberOfDigits;
        while (carry > 0) {
            ans.digit[ans.numberOfDigits++] = carry % base;
            carry /= base;
        }

        return ans;
    }

    friend BigInteger operator * (int b, BigInteger a) {
        return (a * b);
    }

    BigInteger operator *= (int b) {
        (*this) = (*this) * b;
    }

    //  AFISARE
    friend ostream& operator << (ostream& o, BigInteger a) {
        o << a.digit[a.numberOfDigits - 1];
        for (int i = a.numberOfDigits - 2; i >= 0; i--) {
            o << setfill('0') << setw(logBase) << a.digit[i];
        }
        return o;
    }
};

int main() {
  //  freopen("tt.txt", "r", stdin);
    freopen("patrate2.in", "r", stdin);
    freopen("patrate2.out", "w", stdout);

    ios::sync_with_stdio(false);
    cin.tie(0);

    BigInteger ans(1);

    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        ans *= i;
    }
    for (int i = 1; i <= n * n; i++) {
        ans *= 2;
    }
    cout << ans;

    return 0;
}