zhu_a_meng @ 2023-11-18 21:38:40
#include <iostream>
#include <string>
using namespace std;
int mul[1010],sum[1010];
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]++;
}
}
void aaa(int n)
{
mul[1] = 1;
mul[0] = 1;
for(int i = 1;i <= n;i++)
{
mulBIG(mul,i,mul);
}
}
int main()
{
int x;
cin >> x;
for(int i = 1;i <= x;i++)
{
aaa(i);
addBIG(sum,mul,sum);
}
printBIG(sum);
return 0;
}
by 张一2010 @ 2024-01-28 22:24:49
@zhu_a_meng 你的mulBIG高精乘有问题
by 张一2010 @ 2024-01-28 22:26:42
其他的应该没问题,你可以去题解里找一找