缺省源
#include <bits/stdc++.h>
using namespace std;
#ifdef ONLINE_JUDGE
char buf[1 << 23] , * p1 = buf , * p2 = buf , obuf[1 << 23] , * O = obuf;
#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
#endif
inline int read() {
int x = 0 , f = 1;char ch = getchar();
while (!isdigit(ch)) { if (ch == '-') f = -1;ch = getchar(); }
while (isdigit(ch)) x = x * 10 + (ch ^ 48) , ch = getchar();
return x * f;
}
#define endl '\n'
typedef long long ll;
typedef pair<int, int> pi;
const int N = 2e5 + 10;
int n;
signed main() {
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
return 0;
}取模整形
class mint {
private:
long long value;
long long mod(long long x) const {
if (Mod != 0) {
x %= Mod;
if (x < 0) x += Mod;
}
return x;
}
public:
mint(long long v = 0) : value(mod(v)) {}
long long Get() const { return value; }
mint operator+(const mint& other) const {
return mint(value + other.value);
}
mint operator-(const mint& other) const {
return mint(value - other.value);
}
mint operator*(const mint& other) const {
return mint(value * other.value);
}
mint& operator=(long long v) {
value = mod(v);
return *this;
}
friend std::ostream& operator<<(std::ostream& os, const mint& num) {
os << num.value;
return os;
}
friend std::istream& operator>>(std::istream& is, mint& num) {
long long temp;
is >> temp;
num.value = num.mod(temp);
return is;
}
};快读
记得改类型(读入 long long 时)
#ifdef ONLINE_JUDGE
char buf[1 << 23] , * p1 = buf , * p2 = buf , obuf[1 << 23] , * O = obuf;
#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
#endif
inline int read() {
int x = 0 , f = 1;char ch = getchar();
while (!isdigit(ch)) { if (ch == '-') f = -1;ch = getchar(); }
while (isdigit(ch)) x = x * 10 + (ch ^ 48) , ch = getchar();
return x * f;
}静态 RMQ
线段树
struct tree {
int ma[N * 4], val[N];
#define mid (l + r >> 1)
#define ls p << 1, l, mid
#define rs (p << 1) | 1, mid + 1, r
void build(int p, int l, int r) {
if(l == r) ma[p] = val[l];
else build(ls), build(rs), ma[p] = max(ma[p << 1], ma[p << 1 | 1]);;
}
int getmax (int p, int l, int r, int ql, int qr) {
if(ql <= l && r <= qr) return ma[p];
if(ql > r || qr < l) return -inf;
return max(getmax(ls, ql, qr), getmax(rs, ql, qr));
}
};