fish_gugu @ 2023-04-20 20:17:21
#include <iostream>
#include <string>
using namespace std;
int mul[1010];
int sum[1000010];
void addBIG(int x[], int y[], int z[])
{
z[0] = max(x[0], y[0]);
for (int i = 1; i <= z[0]; i++)
z[i] = x[i] + y[i];
for (int i = 1; i <= z[0]; i++)
{
z[i + 1] += z[i] / 10;
z[i] %= 10;
if (z[z[0] + 1] > 0) z[0]++;
}
}
void i2BIG(int n, int a[])
{
int la = 0;
while (n > 0)
{
la++;
a[la] = n % 10;
n /= 10;
}
if (la == 0) la++;
a[0] = la;
}
void printBIG(int a[])
{
int la = a[0];
for (int i = la; i >= 1; i--)
{
cout << a[i];
}
cout << endl;
}
void mulBIG(int x[], int y, int z[])
{
z[0] = x[0];
for (int i = 1; i <= z[0]; i++)
z[i] = x[i] * y;
for (int i = 1; i <= z[0]; i++)
{
z[i + 1] += z[i] / 10;
z[i] %= 10;
if (z[z[0] + 1] > 0) z[0]++;
}
}
int main()
{
int n;
cin >> n;
i2BIG(1,mul);
for(int i = 1;i <= n;i++)
{
for(int j = 1;j <= i;j++)
{
mulBIG(mul,j,mul);
}
addBIG(mul,sum,sum);
i2BIG(1,mul);
}
printBIG(sum);
return 0;
}