fsc0190 @ 2024-04-16 17:03:45
#include<bits/stdc++.h>
using namespace std;
int n;
int a[101] = {0},s[101] = {0};
void cnt(int x)
{
int sum = 0;
for (int i=100;i>=0;i--)
{
a[i] = a[i]*x+sum;
sum = a[i]/10;
a[i] = a[i]%10;
}
}
void cmp()
{
int sum = 0;
for (int i=100;i>=0;i--)
{
s[i] = s[i]+a[i]+sum;
sum = s[i]/10;
s[i] = s[i]%10;
}
}
void num()
{
int sum = 0;
for (int i=0;i<=100;i--)
{
if (s[i] != 0)
{
sum = i;
break;
}
}
for (int i=sum;i<=100;i++)
{
printf("%d",s[i]);
}
}
int main()
{
cin >> n;
s[100] = 1;
a[100] = 1;
for (int i=2;i<=n;i++)
{
cnt(i);
cmp();
}
num();
return 0;
}
by h120316 @ 2024-04-27 10:35:26
高精度用错了,求关
by wahe @ 2024-05-03 17:40:21
@fsc0190 你的num函数中i++写成了i--(求关)