fzc888888882023 @ 2024-07-30 18:02:24
#include <iostream>
#define un128 unsigned __int128
#define ll long long
using namespace std;
un128 read()
{
char arr[30];
unsigned __int128 res = 0;
scanf("%s", arr);
for (int i = 1; i <= strlen(arr); i++)
{
res *= 10;
res += arr[i] - '0';
}
return res;
}
un128 fac(ll n)
{
un128 sum = 1;
for (ll i = 1; i <= n; i++)
{
sum *= i;
}
return sum;
}
void print(un128 num)
{
if (num > 9)
{
print(num / 10);
}
putchar(num % 10 + '0');
}
int main()
{
int n;
cin >> n;
un128 ans = 0;
for (int i = 1; i <= n; i++)
{
ans += fac(i);
}
print(ans);
return 0;
}
by OIerWu_829 @ 2024-07-30 18:06:06
@fzc888888882023 正解是高精度。
by MLE_Automaton @ 2024-07-30 18:09:07
理论来说考试不让用Int128的,最好写高精度
by NullPointerExpection @ 2024-07-30 18:09:29
@fzc888888882023 这题会爆__int128
by Alliy666 @ 2024-07-30 18:14:44
@ChenXiJie2013 现在已经让了
by 初星逝者 @ 2024-07-30 18:26:08
@ChenXiJie2013 可
by fzc888888882023 @ 2024-07-30 20:15:52
@wzj0829 懂了