I heard someone is longer than my code.
Sacrifice the ancestral high-precision type of water wave ...
Probably also on the 9k code such a child ...
Code:
#pragma GCC optinize (3) #pragma comment (linker, "/stack:102400000,10240000") #include <bits/stdc++.h> #define LEN 35663//100001using namespace Std;class big_int{//54724 private:int A[len]; int Len; BOOL F,p; Public://Initialize constructor operation void Clear () {memset (a,0,sizeof a); Len=1; f=0; P=0; } big_int () {clear (); } big_int (Int x) {clear (); (*this) =x; } big_int (const Big_int &x) {clear (); (*this) =x; }//Assignment operation Big_int operator = (const char *ch) {len=strlen (CH); if (ch[0]== '-') {f=1;len--; for (int i=1;i<=len;i++) a[i]=ch[len-i+1]-' 0 '; return *this; } for (int i=1;i<=len;i++) a[i]=ch[len-i]-' 0 '; return *this; } Big_int operator = (const Int d) {char Ch[len]; sprintf (CH, "%d", d); *this=ch; return *this; }//Four basic Operation Big_int operator + (Big_int b) {if (f==1&&b.f==0) { f=0; Return B (*this); } else if (f==0&&b.f==1) {b.f=0; Return (*this)-B; } big_int C; C.clear (); int L=max (Len,b.len); for (int i=1;i<=l;i++) {c.a[i]+=a[i]+b.a[i]; C.A[I+1]=C.A[I]/10; c.a[i]%=10; } if (c.a[l+1]) l++; C.len=l; c.f=f&&b.f; return C; } big_int operator-(Big_int b) {if (f==1&&b.f==0) {b.f=1; Return B + (*this); } if (f==0&&b.f==1) {b.f=0; Return B + (*this); } if (f==1&&b.f==1) {b.f=0; Return B + (*this); } big_int C; C.clear (); if ((*this) <b) {swap (*THIS,B); c.f=1; } int L=max (Len,b.len); for (int i=1;i<=l;i++) {c.a[i]+=a[i]-b.a[i]; if (c.a[i]<0) c.a[i+1]--, c.a[i]+=10; } while (c.a[l]==0&&l>0) l--; if (l==0) l=1; C.len=l; return C; } big_int operator * (Big_int b) {Big_int C; C.clear (); int l=len+b.len-1; for (int i=1;i<=len;i++) {for (int j=1;j<=b.len;j++) {c. A[I+J-1]+=A[I]*B.A[J]; C.A[I+J]+=C.A[I+J-1]/10; c.a[i+j-1]%=10; }} while (c.a[l+1]!=0) l++; C.len=l; if ((f==0&&b.f==1) | | | (f==1&&b.f==0)) c.f=1; return C; } big_int operator/(Big_int b) {if (b==0) {throw 0x7f; } big_int a= (*this), c,t; c.len=len-b.len+1; for (int i=c.len;i>=0;i--) {if (a==0) break; T.clear (); t=b<<i; while (t<=a) {c.a[i+1]++;a-=t;} } while (!c.a[c.len]&&c.len>0) c.len--; if (c.len==0) c.len=1; if (f==0&&b.f==1) c.f=1; else if (f==1&&b.f==0) c.f=1; return C; } big_int operator% (Big_int b) {big_int c= (*this)/b; B=b*c; Return (*this)-B; }//comparison operation BOOL operator <= (Big_int b) {return (*this) <b| | (*this) ==b); } bool operator >= (Big_int b) {return (*this) >b| | (*this) ==b); } bool operator < (Big_int b) {if ((*this) ==b) return 0; if (F&&!B.F) return 1; else if (!F&&B.F) return 0; else if (F==b.f&&f==0&&len<b.len) return 1; else if (F==b.f&&f==0&&len>b.len) return 0; else if (F==b.f&&f==1&&len<b.len) return 0; else if (F==b.f&&f==1&&len>b.len) return 1; else {int flag=-1; for (int i=len;i>=1;i--) {if (A[i]>b.a[i]) { flag=0; Break } else if (A[i]<b.a[i]) { Break }} if (F==1) Flag=!flag; else if (f==-1) return 0; return flag; }} bool operator = = (Big_int b) {if (F!=B.F) return 0; if (Len!=b.len) return 0; for (int i=len;i>=1;i--) {if (A[i]!=b.a[i]) return 0; } return 1; } bool Operator! = (Big_int b) {return! ( (*this) ==b); } bool Operator! = (int b) {return! ( (*this) ==b); } bool operator = = (int b) {big_int a=b; Return a== (*this); } bool operator > (Big_int b) {if (! ( (*this) <b) &&! ((*this) ==b)) return 1; else return 0; }//increment (subtract) operation Big_int operator + + (Int) {if (f==1&&!p) { P=1; (*this)--; return *this; } a[1]++; int t=1; while (a[t]>9) {a[t+1]++; a[t]%=10; t++; } while (a[len+1]) len++; if (len==1&&a[len]==0) f=0; P=0; return *this; } big_int Operator-(INT) {if (f==1&&!p) {(*this) + +; P=1; return *this; } int t=1; a[t]--; while (a[t]<0) {a[t+1]--; a[t]+=10; t++; } while (a[len+1]) len++; if (len==1&&a[len]==0) f=0; P=0; return *this; }//Arithmetic extension//addition related Big_int operator + (Int b) {Big _int c=b; Return (*this) +c; } void operator + = (Big_int b) {(*this) = (*this) +b; } void operator + = (int b) {big_int c=b; (*this) = (*this) +c; }//Subtraction related big_int operator-(Int b) {big_int c=b; Return (*this)-C; } void Operator-= (Big_int b) {(*this) = (*this)-B; } void operator-= (int b) {big_int c=b; (*this) = (*this)-B; }//multiplication related inline big_int operator * (Int b) {/*big_int c=b; Return (*this) *c;*/big_int C; for (int i=1;i<=len;i++) {c.a[i]+=a[i]*b; C.A[I+1]=C.A[I]/10; c.a[i]%=10; } C.len=len; while (c.a[c.len+1]!=0) {c.len++; C.A[C.LEN+1]=C.A[C.LEN]/10; c.a[c.len]%=10; } return C; } void operator *= (Big_int b) {(*this) = (*this) *b; } void operator *= (int b) {(*this) = (*this) *b; }//Division related Big_int operator/(Int b) {big_int c=b; Return (*this)/C; } void operator/= (int b) {big_int c=b; (*this) = (*this)/C; } void operator/= (Big_int b) {(*this) = (*this)/b; }//modulo related big_int operator% (Int b) {big_int c=b; Return (*this)%c; } void operator%= (int b) {big_int c=b; (*this) = (*this)%c; } void operator%= (Big_int b) {(*this) = (*this)%b; }//Special operation Big_int ABS () {Big_int c= (*this); C.f=0;return C; } big_int operator << (Int b)//decimal-based left shift, so is equivalent to *10 {big_int C; for (int i=b+1;i<=len+b;i++) c.a[i]=a[i-b]; C.len=len+b; return C; } big_int operator >> (Int b) {Big_int C; for (int i=b+1;i<=len;i++) {c.a[i-b]=a[i]; } c.len=len-b; return C; } Big_int Pow (Big_int b) {big_int a= (*this), Ans=1; while (b!=0) {if (b.a[1]&1) ans*=a; A*=a; b/=2; } return ans; } Big_int Pow (Int b) {big_int a= (*this), Ans=1; while (b!=0) {if (b&1) ans*=a; A*=a; b/=2; } return ans; } big_int sqrt () {big_int x= (*this), a= (*this); for (int i=1;i<=len*10;i++) x= (x+a/x)/2; return x; }//conversion function void output () {while (a[len]==0)--len; for (register int i=len;i>=1;--i) Putchar (a[i]+ ' 0 '); } string Cpp_str () {string str; if (len==0) {str= "0"; return str; } if (f==1&&! ( len==1&&a[1]==0)) Str.push_back ('-'); for (int i=len;i>=1;i--) str.push_back (a[i]+ ' 0 '); return str; }}a,s;istream& operator >> (IStream &in,big_int &a) {string str; in>>str; A=str.c_str (); return in;} ostream& operator << (ostream &out,big_int &a) {out<<a.cpp_str (); return out;} int main () {int n; cin>>n; A=1,s=1; for (int i=2;i<=n;i++) {a*=i;s+=a; } Cout<<s;}
Luogu P1009 "factorial sum"