Files
python/TangDou/LuoGuBook/第8章模拟与高精度/P1009_1.cpp

19 lines
548 B
C++
Raw Normal View History

2025-08-30 18:35:01 +08:00
#include <bits/stdc++.h>
using namespace std;
//本题有坑,使用长整也过不了洛谷的用例,因为它的用例是22,
//需要高精度,也就是乘法高精度+加法高精度
typedef long long LL;
int n;
LL res;
int main() {
cin >> n;
for (int i = 1; i <= n; i++) { // 1~n
LL f = 1; // 基底
for (int j = 1; j <= i; j++) f *= j; // f =n!
res += f; // 1!+2!+3!+...+n!
}
cout << res << endl;
return 0;
}