蒟蒻の笔记
STL二分查找函数
int N = 10, a[] = {1, 1, 2, 4, 5, 5, 7, 7, 9, 9}, x = 5;
int i = lower_bound(a, a + N, x) - a, j = upper_bound(a, a + N, x) - a;
a[0] ~ a[i - 1] 为小于x的元素, a[i] ~ a[j - 1] 为等于x的元素,
a[j] ~ a[N - 1] 为大于x的元素
vector
v.front()
back()
v.back()
v.at(pos)//返回下标为pos的元素
v.end()//返回队列末元素的下标
v.begin()//用法类似于end
v.push_back(a)//向队尾加入a
v.empty()//队列为空返回true,否则为false
v.pop_back()//删除队尾元素
__int128//大整数(10的18次方)

#include<iostream> using namespace std; inline __int128 read() { __int128 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 << 1) + (x << 3) + (ch - '0'); ch = getchar(); } return x * f; } void print(__int128 x) { if (x < 0) { putchar('-'); x = -x; } if (x > 9) print(x / 10); putchar(x % 10 + '0'); } int main() { __int128 x = read(); print(x); return 0; }
该博客主要用于辅助本人自己的OI学习
有任何误导虚心请求各位神犇赐教