Pagini recente » Cod sursa (job #3208797) | Cod sursa (job #3255483) | Cod sursa (job #2485073) | Cod sursa (job #120487) | Cod sursa (job #2784990)
#include <fstream>
#include <algorithm>
#include <cstring>
using namespace std;
FILE *fin , *fout ;
const int MAX_digits = 1024 ;
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;
}