卡常技巧
swap
a^=b^=a^=b;//without function
<=
inline void swap(int &x,int &b){
a^=b^=a^=b;
}
<=
swap(a,b);//stl
究极快读
namespace fast_IO {//without negative number
char getchar() {
static const int IN_LEN = 1 << 18 | 1;
static char buf[IN_LEN], *s, *t;
return (s == t) && (t = (s = buf) + fread(buf, 1, IN_LEN, stdin)), s == t ? -1 : *s++;
}
int read() {
int num = 0;
char c;
while ((c = getchar()) != '-' && c != '+' && (c < '0' || c > '9') && ~c);
num = c ^ 48;
while ((c = getchar()) >= '0' && c <= '9')
num = (num << 1) + (num << 3) + (c ^ 48);
return num;
}
}
namespace fast_IO {
char buf[N], *s, *t;
char getchar() {
return (s == t) && (t = (s = buf) + fread(buf, 1, N, stdin)), s == t ? -1 : *s++;
}
int read() {
int num = 0;
char c;
bool tag = false;
while ((c = getchar()) != '-' && c != '+' && (c < '0' || c > '9') && ~c);
if (c == '-')tag = true;
else num = c ^ 48;
while ((c = getchar()) >= '0' && c <= '9')
num = (num << 1) + (num << 3) + (c ^ 48);
if (tag)return -num;
return num;
}
}
GCD
inline int gcd(int a,int b){if(!b)return a;while(b^=a^=b^=a%=b);return a;
氧气加速
#pragma GCC optimize(2)
#pragma GCC optimize(3,"Ofast","inline")

浙公网安备 33010602011771号