Cod sursa(job #2905302)

Utilizator mihaistamatescuMihai Stamatescu mihaistamatescu Data 20 mai 2022 18:29:50
Problema Patrate2 Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.61 kb
#include <fstream>

using namespace std;
int h[100000], n;

void produs(int *h, int x) {
    int i, 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 main() {
    ifstream fin("patrate2.in");
    ofstream fout("patrate2.out");
    fin >> n;
    h[0] = h[1] = 1;
    for (int i = 2; i <= n; i++) {
        produs(h, i);
    }
    for (int i = 1; i <= n * n; i++) {
        produs(h, 2);
    }
    for (int i = h[0]; i >= 1; i--) {
        fout << h[i];
    }
    return 0;
}