24 lines
499 B
C++
24 lines
499 B
C++
#include <bits/stdc++.h>
|
|
|
|
using namespace std;
|
|
typedef long long LL;
|
|
//高精度+高精度
|
|
|
|
//高精度*低精度
|
|
|
|
int main() {
|
|
int n;
|
|
cin >> n;
|
|
LL res = 0;
|
|
LL f = 1;
|
|
for (int i = 1; i <= n; i++) {
|
|
// f =i!
|
|
// 3!= 3*2*1
|
|
// 4!=4*3*2*1
|
|
f *= i; //计算i! =(i-1)! * i 举栗子: 4!= 4* 3!
|
|
res += f; //计算阶乘的和 res= 1!+2!+3!+...+n!
|
|
}
|
|
//输出要需要改
|
|
cout << res << endl;
|
|
return 0;
|
|
} |