//求阶乘和 #include#include #include using namespace std;#define E 1001struct bign{ int len,v[E]; bign operator + (const bign& b) const { bign c; memset(c.v,0,sizeof(c.v)); c.len = max(len,b.len); for(int i = 0;i < c.len;i++) c.v[i] = v[i] + b.v[i]; for(int i = 0;i < c.len;i++) c.v[i + 1] += c.v[i] / 10,c.v[i] %= 10; if(c.v[c.len]) c.len++; return c; } bign operator * (const bign& b) const { bign c; memset(c.v,0,sizeof(c.v)); c.len = len + b.len + 1; for(int i = 0;i < len;i++) for(int j = 0;j < b.len;j++) { c.v[i + j] += v[i] * b.v[j]; c.v[i + j + 1] += c.v[i + j] / 10,c.v[i + j] %= 10; } while(c.v[c.len] == 0) c.len--; c.len++; return c; } bool operator < (const bign& b) const { if(len > b.len) return 0; if(len < b.len) return 1; for(int i = 0;i < len;i++) { if(v[i] > b.v[i]) return 0; if(v[i] < b.v[i]) return 1; } } bool operator > (const bign &b) const { return !(*this < b); } bool operator <= (const bign& b) const { return !(*this > b); } bool operator >= (const bign& b) const { return !(*this < b); } bool operator == (const bign& b) const { return *this <= b && b <= *this; } bign operator = (char* s) { len = strlen(s); memset(v,0,sizeof(v)); for(int i = 0;i < len;i++) v[i] = s[len - i - 1] - '0'; return *this; } bign operator = (int x) { char s[E]; sprintf(s,"%d",x); *this = s; return *this; } bign operator += (const bign& b) { return *this = *this + b; }};inline void print(bign a){ for(int i = a.len - 1;i >= 0;i--) printf("%d",a.v[i]); cout << endl;}bign a,ans;int main(){ int n; cin >> n; a = 1,ans = 1; //print(a); for(int i = 2;i <= n;i++) { bign b; b = i; //print(b); a = a * b,ans = a + ans; //print(a); } print(ans); return 0;}