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

18 lines
421 B
C++
Raw Normal View History

2025-08-30 18:35:01 +08:00
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n; // n!+(n-1)!+(n-2)!+...+1!
int sum = 0; //结果,累加和
for (int i = n; i >= 1; i--) { //枚举 n,n-1,n-2,....,1
//计算n这个数字的阶乘
int res = 1;
for (int j = i; j >= 1; j--) res *= j;
sum += res;
}
cout << sum << endl;
return 0;
}