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