'commit'
This commit is contained in:
33
TangDou/LuoGuBook/第8章模拟与高精度/P1009_Prepare.cpp
Normal file
33
TangDou/LuoGuBook/第8章模拟与高精度/P1009_Prepare.cpp
Normal file
@@ -0,0 +1,33 @@
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
typedef long long LL;
|
||||
|
||||
//母题
|
||||
//求n阶乘
|
||||
LL f(int n) {
|
||||
LL s = 1;
|
||||
for (int i = 1; i <= n; i++) s *= i;
|
||||
return s;
|
||||
}
|
||||
|
||||
int main() {
|
||||
//INT_MAX
|
||||
//2147483647
|
||||
// s=1!+2!+3!+...+n!
|
||||
// 3!=3*2*1
|
||||
// 4!=4*3*2*1 四步
|
||||
// 4!=4*3! 一步,3!我知道
|
||||
|
||||
//20!=20*19*18*....*1
|
||||
LL s = 0;
|
||||
for (int i = 1; i <= 20; i++) s += f(i);
|
||||
cout << s << endl;
|
||||
|
||||
|
||||
LL t = 1;
|
||||
s = 0;
|
||||
for (int i = 1; i <= 20; i++) t = t * i, s += t;
|
||||
cout << s << endl;
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user