LiamZou @ 2024-01-31 22:47:44
#include <bits/stdc++.h>
using namespace std;
int jiecheng[105], ans[105];
int main()
{
int n;
cin >> n;
jiecheng[0] = ans[0] = 1;
for (int i = 2; i <= n; i++)
{
for (int j = 0; j < 100; j++)
{
jiecheng[j] = jiecheng[j] * i;
}
for (int j = 0; j < 100; j++)
{
if (jiecheng[i] >= 10)
{
jiecheng[j + 1] += jiecheng[j] / 10;
jiecheng[j] %= 10;
}
}
for (int j = 0; j < 100; j++)
{
ans[j] += jiecheng[j];
if (ans[j] >= 10)
{
ans[j + 1] += ans[j] / 10;
ans[j] %= 10;
}
}
}
int idx = 100;
for (int i = 100; i >= 0; i--)
{
idx = i;
if (ans[i] != 0)
{
break;
}
}
for (int i = idx; i >= 0; i--)
{
cout << ans[i];
}
return 0;
}