#include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 10;
struct Bigint{
int len, a[N];
Bigint(int x = 0){
memset(a, 0, sizeof a);
len = 0;
if (x == 0) len = 1;
while (x){
a[len++] = x % 10;
x /= 10;
}
}
int &operator[](int i){
return a[i];
}
void flatten(int L){
len = L;
for (int i = 0; i < len; i++){
a[i + 1] += a[i] / 10;
a[i] %= 10;
}
while (a[len] == 0 && len > 0) len--;
len++;
}
void print(){
for (int i = len - 1; i >= 0; i--) printf("%d", a[i]);
puts("");
}
};
Bigint operator+(Bigint a, Bigint b){
Bigint c;
int len = max(a.len, b.len);
for (int i = 0; i < len; i++) c[i] += a[i] + b[i];
c.flatten(len + 1);
return c;
}
Bigint operator*(Bigint a, int b){
Bigint c;
int len = a.len;
for (int i = 0; i < len; i++) c[i] = a[i] * b;
c.flatten(len + 500);
return c;
}
int main(){
Bigint ans(0), fac(1);
int n;
cin >> n;
for (int i = 1; i <= n; i++){
fac = fac * i;
ans = ans + fac;
}
ans.print();
return 0;
}
大整数运算,使用vector<>实现