Cod sursa(job #2784991)

Utilizator andreipirjol5Andrei Pirjol andreipirjol5 Data 17 octombrie 2021 19:50:32
Problema Patrate2 Scor 90
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 1.6 kb
#include <fstream>
#include <algorithm>
#include <cstring>
using namespace std;
FILE *fin , *fout ;
const int MAX_digits = 3000 ;
const int BASE = 10 ;
class HUGENR
{
private:
    int x[MAX_digits] ;
public:
    HUGENR()
    {
        memset(x, 0, sizeof(x)) ;
        x[0] = 1 ;
    }
    HUGENR(int n)
    {
        memset(x, 0, sizeof(x)) ;
        x[0] = 0 ;
        do
        {
            x[++x[0]] = n % 10 ;
            n = n / 10 ;
        }
        while(n) ;
    }
    HUGENR(const HUGENR &other)
    {
        memcpy(x, other.x, sizeof(other.x)) ;
    }
    void print()
    {
        for(int i = x[0] ; i >= 1 ; i--)
            fprintf(fout , "%d" , x[i]) ;
        fprintf(fout , "\n") ;
    }
    HUGENR operator* (int k) ;
};
HUGENR HUGENR::operator* (int k)
{
    HUGENR c ;
    int i, tr, aux ;
    c.x[0] = x[0] ;
    for(i = 1 ; i <= c.x[0] ; i++)
        c.x[i] = x[i] * k ;
    for(i = 1, tr = 0 ; i <= c.x[0] ; i++)
    {
        aux = c.x[i] + tr ;
        c.x[i] = aux % BASE ;
        tr = aux / BASE ;
    }
    while(tr)
    {
        c.x[0]++;
        c.x[c.x[0]] = tr % BASE ;
        tr = tr / BASE ;
    }
    return c ;
}
int main()
{
    fin = fopen("patrate2.in" , "r") ;
    fout = fopen("patrate2.out" , "w") ;
    int n ;
    fscanf(fin , "%d" , &n) ;
    ///(n^n * n) * n!
    int exp = n * n ;
    HUGENR rez(1) ;
    for(int i = 1 ; i <= exp ; i++)
        rez = rez * 2 ;
    for(int i = 1 ; i <= n ; i++)
        rez = rez * i ;
    rez.print() ;
    fclose(fin) ;
    fclose(fout) ;
    return 0;
}
//158 * 2 100000