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