Easy-to-use templates ...... Take it as needed
If any bug is found during use, leave a message to indicate
1. Do I feel like I am not enough time to play the codeforces game? In fact, if you look at God's code, you will find that they just put a pile of header files in the default value of the compiler to save time, and there are some magical # define ...... For balabala, I typed my common CF header files and some frequently used define files, and quickly read them into templates.
#include<cstdio>#include<iostream>#include<cstring>#include<cstdlib>#include<algorithm>#include<cmath>#include<queue>#include<deque>#include<set>#include<map>#include<ctime>#define LL long long#define inf 0x7ffffff#define pa pair<int,int>#define pi 3.1415926535897932384626433832795028841971using namespace std;inline LL read(){ LL x=0,f=1;char ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();} while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();} return x*f;}int main(){}
2. High Precision is really a headache. Every write, subtraction, multiplication, division, and read/output are troublesome ...... Currently, the addition and subtraction of non-negative high-precision integers by MINMAX ...... Place Template
# Define MX 100 // high-precision struct Gaojing {int Len; int A [mx + 10] ;}; // defines the inline void set0 (Gaojing & S) of the high-precision non-negative type) // High Precision cleared {S. len = 1; for (INT I = 1; I <= mx + 5; I ++) s. A [I] = 0;} inline void inputn (Gaojing & A) // high-precision input {set0 (a); char CH = getchar (); while (CH <'0' | ch> '9') CH = getchar (); While (CH> = '0' & Ch <= '9 ') {. A [. len ++] = CH-'0'; CH = getchar ();}. len --; int change [mx + 15]; for (INT I = 1; I <=. len; I ++) change [I] =. A [I]; for (INT I = 1; I <=. len; I ++). A [I] = change [. len-I + 1]; while (. A [. len] = 0). len --;} inline void put (Gaojing A) // high-precision output and line feed {for (INT I =. len; I> = 1; I --) printf ("% d",. A [I]); printf ("\ n");} inline int CMP (const Gaojing & A, const Gaojing & B) // comparison: A <B: 1 A> B:-1 A = B: 0 {if (. len! = B. len) {if (. len <B. len) return 1; else return-1;} For (INT I =. len; I> = 1; I --) if (. A [I] <B. A [I]) return 1; else if (. A [I]> B. A [I]) Return-1; return 0;} inline Gaojing max (const Gaojing & A, const Gaojing & B) // High Precision max {int OPR = CMP (, b); If (OPR = 1) return B; else return a;} inline Gaojing min (const Gaojing & A, const Gaojing & B) // High Precision min {int OPR = CMP (a, B); If (OPR = 1) return a; else return B;} inline Gaojing Operator + (const Gaojing & A, const Gaojing & B) // high-precision addition {Gaojing C; set0 (c); int maxlen = max (. len, B. len); For (INT I = 1; I <= maxlen; I ++) {C. A [I] = C. A [I] +. A [I] + B. A [I]; If (C. A [I]> = 10) {C. A [I + 1] + = C. A [I]/10; C. A [I] % = 10 ;}} C. len = maxlen + 4; while (! C. A [C. len] & C. len> 1) C. len --; return C;} inline Gaojing operator-(const Gaojing & A, const Gaojing & B) // high-precision subtraction, A> B {Gaojing C; set0 (c); Gaojing D; D = A; For (INT I = 1; I <= B. len; I ++) {C. A [I] = D. A [I]-B. A [I]; If (C. A [I] <0) {C. A [I] + = 10; int now = I + 1; while (! D. A [now]) {d. A [now] = 9; now ++;} D. A [now] -- ;}}for (INT I = B. len + 1; I <= D. len; I ++) C. A [I] = D. A [I]; C. len = D. len; while (C. A [C. len] = 0 & C. len> 1) C. len --; return C;} inline Gaojing operator * (const Gaojing & A, const Gaojing & B) // high-precision multiplication {Gaojing C; set0 (C ); 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]; int mxlen =. len + B. len + 5; For (INT I = 1; I <= mxlen; I ++) {C. A [I + 1] + = C. A [I]/10; C. A [I] % = 10;} while (C. A [mxlen] = 0) mxlen --; C. len = mxlen; return C ;}
Updating
Easy-to-use templates (continuous addition)