Files
python/TangDou/LuoGuBook/第8章模拟与高精度/P1009_1.cpp
HuangHai 1f397eca87 'commit'
2025-08-30 18:35:01 +08:00

19 lines
548 B
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#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;
}