'commit'
This commit is contained in:
18
TangDou/LuoGuBook/第8章模拟与高精度/P1009_Study.cpp
Normal file
18
TangDou/LuoGuBook/第8章模拟与高精度/P1009_Study.cpp
Normal file
@@ -0,0 +1,18 @@
|
||||
#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;
|
||||
}
|
||||
Reference in New Issue
Block a user