模板的日常~。~。。。(持续更新中...)

头文件&吧啦吧啦~

 1 #include <set>
 2 #include <map>
 3 #include <list>
 4 #include <queue>
 5 #include <stack>
 6 #include <string>
 7 #include <math.h>
 8 #include <time.h>
 9 #include <vector>
10 #include <stdio.h>
11 #include <sstream>
12 #include <string.h>
13 #include <stdlib.h>
14 #include <iostream>
15 #include <algorithm>
16 using namespace std;
17 /***************************************/
18 typedef vector<int> VI;
19 typedef vector<char> VC;
20 typedef vector<string> VS;
21 typedef set<int> SI;
22 typedef set<string> SS;
23 typedef map<int ,int> MII;
24 typedef map<string,int> MSI;
25 typedef pair<int,int> PII;
26 typedef vector<PII> VII;
27 typedef vector<VI > VVI;
28 /***************************************/
29 #ifdef _WIN32
30 #define ll __int64
31 #else
32 #define ll long long
33 #endif
34 
35 #define mem(a,b) memset(a,b,sizeof(a))
36 #define all(x)  (x).begin(), (x).end()
37 #define sz(x) ((int)(x).size())
38 #define PB push_back
39 #define MP make_pair
40 #define LL(x) ((x)<<1)
41 #define RR(x) ((x)<<1|1)
42 #define sqr(x) ((x)*(x))
43 #define pn()  printf("
")
44 #define sqr(x) ((x)*(x))
45 /***************************************/
46 const int INF = 0x7f7f7f7f;
47 const ll LINF = (1LL<<60);
48 const double eps = 1e-8;
49 const double PIE=acos(-1.0);
50 const int dx[]= {0,-1,0,1};
51 const int dy[]= {1,0,-1,0};
52 const int fx[]= {-1,-1,-1,0,0,1,1,1};
53 const int fy[]= {-1,0,1,-1,1,-1,0,1};
54 /***************************************/
55 void openfile()
56 {
57     freopen("data.in","rb",stdin);
58     freopen("data.out","wb",stdout);
59 }
60 void Scan(int& res)
61 {
62     int flag=0;
63     char ch;
64     while(!(((ch=getchar())>='0'&&ch<='9')||ch=='-'))
65         if(ch==EOF)
66             res=INF;
67     if(ch=='-')
68         flag=1;
69     else if(ch>='0'&&ch<='9')
70         res=ch-'0';
71     while((ch=getchar())>='0'&&ch<='9')
72         res=res*10+ch-'0';
73     res=flag?-res:res;
74 }
75 void Out(int a)
76 {
77     if(a>9)
78         Out(a/10);
79     putchar(a%10+'0');
80 }
81 void Out(ll a)
82 {
83     if(a>9)
84         Out(a/10);
85     putchar(a%10+'0');
86 }
87 /**********************The End OF The Template*****************/
View Code

 

+++++++++++++++++++++++++++++++++++++++++++++ 

数论

+++++++++++++++++++++++++++++++++++++++++++++ 

欧几里得算法

long long gcd(long long a,long long b){
    return b==0?a:gcd(b,a%b);
}

扩展欧几里得算法

long long extgcd(long long a,long long b,long long& x,long long& y){
    long long d=a;
    if (b!=0){
        d=extgcd(b,a%b,y,x);
        y-=(a/b)*x;
    }
    else{
        x=1,y=0;
    }
    return d;
}

快速幂取余

typedef long long ll;
ll mod_pow(ll x,ll y,ll mod){
    ll res=1;
    while (n>0){
        if (n&1) res=res*x%mod;
        x=x*x%mod;
        n>>=1;
    }
    return res;
}

 

+++++++++++++++++++++++++++++++++++++++++++++++ 

图论

+++++++++++++++++++++++++++++++++++++++++++++++

+++++++++++++++++++++++++++++++++++++++++++++++

计算几何

+++++++++++++++++++++++++++++++++++++++++++++++

原文地址:https://www.cnblogs.com/PJQOOO/p/4699404.html