Cod sursa(job #2212208)

Utilizator Moise_AndreiMoise Andrei Moise_Andrei Data 13 iunie 2018 16:36:39
Problema Patrate2 Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.63 kb
#include <iostream>
#include <fstream>
using namespace std;
ifstream in("patrate2.in");
ofstream out("patrate2.out");
int v[1000100];
int n, i;
void f(int x)
{
    int t = 0;
    for(int i = 1; i <= v[0]; ++i)
    {
        t += x * v[i];
        v[i] = t % 10;
        t /= 10;
    }
    while(t)
    {
        v[0] ++;
        v[v[0]] = t % 10;
        t /= 10;
    }
}
int main()
{
    in >> n;
    v[0] = v[1] = 1;
    for(int i = 2; i <= n; ++i)
        f(i);
    for(int i = 1; i <= n; ++i)
        for(int j = 1; j <= n; j ++)
            f(2);
    for(int i = v[0]; i > 0; --i)
        out << v[i];
}