Cod sursa(job #2490520)

Utilizator ioana0211Ioana Popa ioana0211 Data 10 noiembrie 2019 14:16:27
Problema Patrate2 Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.87 kb
#include <iostream>
#include <fstream>
#include <cmath>
using namespace std;
ifstream fin ("patrate2.in");
ofstream fout ("patrate2.out");
const int MAXN=1000004;
struct Huge
{
    int data[MAXN];
};
void mult_with_scalar(Huge &x, int y)
{
    int t = 0;
    for (int i = 1; i <= x.data[0]; i++)
    {
        x.data[i] = x.data[i] * y + t;
        t = x.data[i] / 10;
        x.data[i] %= 10;
    }
    while (t) {
        x.data[++x.data[0]] = t % 10;
        t /= 10;
    }
}
void print(const Huge &h)
{
    for (int i = h.data[0]; i >= 1; i--)
        fout << h.data[i];
}
Huge pos;
int main()
{
    int n;
    fin>>n;
    pos.data[0]=1;
    pos.data[1]=1;
    for(int i=1; i<=n; i++)
    {
        mult_with_scalar(pos, i);
    }
    for(int i=1; i<=n*n; i++)
    {
        mult_with_scalar(pos, 2);
    }
    print(pos);
    return 0;
}