Pagini recente » Cod sursa (job #2779680) | Cod sursa (job #1839538) | Cod sursa (job #540829) | Cod sursa (job #1645242) | Cod sursa (job #2274127)
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <math.h>
#include <string.h>
using namespace std;
struct BigInt {
char digits[3005];
int size = 0;
void add(BigInt &other) {
int c = 0;
size = max(size, other.size);
for (int i = 0; i < size; ++i) {
int sum = digits[i] + other.digits[i] + c;
digits[i] = sum % 10;
c = sum / 10;
}
if (c > 0) {
digits[size] = c;
size++;
}
}
void sub(BigInt &other) {
int c = 0;
int bound = min(size, other.size);
for (int i = 0; i < bound; ++i) {
int sum = digits[i] - (other.digits[i] + c);
if (sum < 0) {
sum += 10;
c = 1;
}
else {
c = 0;
}
digits[i] = sum % 10;
}
while (c > 0) {
digits[bound]--;
if (digits[bound] < 0) {
digits[bound] = 9;
c = 1;
}
else {
c = 0;
}
bound++;
}
}
void multiply(int s) {
int c = 0;
for (int i = 0; i < size; ++i) {
int sum = digits[i] * s + c;
digits[i] = sum % 10;
c = sum / 10;
}
while (c > 0) {
digits[size] = c % 10;
c /= 10;
size++;
}
}
void multiply(BigInt& other) {
BigInt result = BigInt(0);
for (int i = 0; i < other.size; ++i) {
int ndx = i;
int c = 0;
for (int j = 0; j < size; ++j) {
int product = other.digits[i] * digits[j] + result.digits[ndx] + c;
result.digits[ndx] = product % 10;
result.size = max(result.size, ndx + 1);
c = product / 10;
ndx++;
}
if (c > 0) {
result.digits[ndx] = c;
result.size = max(result.size, ndx + 1);
}
}
size = result.size;
for (int i = 0; i < size; ++i) {
digits[i] = result.digits[i];
}
}
BigInt() {
BigInt(0);
}
BigInt(int n) {
memset(digits, 0, sizeof(digits));
while (n > 0) {
digits[size] = n % 10;
n /= 10;
size++;
}
size = max(size, 1);
}
BigInt(char* s) {
size = strlen(s);
int j = 0;
for (int i = size - 1; i >= 0; --i) {
digits[j] = s[i] - '0';
j++;
}
}
void print() {
for (int i = size - 1; i >= 0; --i) {
printf("%d", digits[i]);
}
}
};
int main() {
freopen("patrate2.in", "r", stdin);
freopen("patrate2.out", "w", stdout);
int n;
scanf("%d", &n);
BigInt result = BigInt(1);
for (int i = 2; i <= n; ++i) {
result.multiply(i);
}
for (int i = 0; i < n * n; ++i) {
result.multiply(2);
}
result.print();
return 0;
}