qyd0816 @ 2023-07-30 20:33:59
#include<iostream>
using namespace std;
int a[250], b[250], c[300], i, j, k,a_len,p,c_len;
int main()
{
int n;
cin >> n;
for (i = 1; i <= n; i++)
{
p = i;
a_len = -1;
while (p > 0)
{
a_len++;
a[a_len] = p % 10;
p /= 10;
}
for (j = 0; j <= a_len ; j++)//gs
{
for (k = 1; k < i; k++)
{
a[j] *= k;
}
c[j] += a[j];
}
for (k = 0; k < 250; k++)
{
if (c[k] >= 10)
{
c[k + 1] += c[k]/10;
c[k] %= 10;
}
}
}
c_len = 250;
while(c[c_len-1]==0)
c_len--;
for (j = c_len-1; j >=0 ; j--)
cout << c[j];
return 0;
}
by Sun_Email @ 2023-07-30 21:05:26
for (j = 0; j <= a_len ; j++)//gs
{
for (k = 1; k < i; k++)
{
a[j] *= k;
}
c[j] += a[j];
}
爆int了吧(这里a[j]可能>=(k-1)!)
@qyd0816