Cod sursa(job #1204322)

Utilizator tudorv96Tudor Varan tudorv96 Data 2 iulie 2014 17:18:44
Problema Patrate2 Scor 50
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.67 kb
#include <fstream>
#include <iomanip>
using namespace std;

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

const int N = 1e5 + 5, Baza = 1e6;

int sol[N], n;

inline void multiply(int nr[], int x) {
    int t = 0, i = 1;
    for (; nr[i] || t; ++i, t/= Baza)
        nr[i] = (t += nr[i] * x) % Baza;
    nr[0] = i - 1;
}

int main() {
    fin >> n;
    sol[0] = sol[1] = 1;
    for (int i = 2; i <= n; ++i)
        multiply(sol, i);
    for (int i = 1; i <= n * n; ++i)
        multiply(sol, 2);
    fout << sol[sol[0]];
    sol[0]--;
    for (int i = sol[0]; i; --i)
        fout << setw(6) << setfill('0') << sol[i];
    return 0;
}