Cod sursa(job #1204143)

Utilizator apopeid15Apopei Daniel apopeid15 Data 2 iulie 2014 09:18:37
Problema Patrate2 Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.68 kb
#include <fstream>
#include <iomanip>
using namespace std;
ifstream fin("patrate2.in");
ofstream fout("patrate2.out");
int n, V[100000];
const int Base = 1000000;
 
inline void mul (int A[], int B)
{
    int i, t = 0;
    for (i=1; i<=A[0] || t; i++, t /= Base)
        A[i] = (t += A[i] * B) % Base;
    A[0] = i - 1;
}
 
int main()
{
    fin >> n;
    V[0] = V[1] = 1;
    for (int i=1; i<=n; i++)
    {
        mul (V, i);
        for (int j=1; j<=n; j++)
        {
            mul (V, 2);
        }
    }
    fout << V[V[0]];
    V[0]--;
    for (int i=V[0]; i>=1; i--) fout << setw(6) << setfill('0') << V[i];
    fout << '\n';
    fout.close();
    return 0;
}