@Dmaxiya
2023-03-11T11:38:15.000000Z
字数 1546
阅读 1123
板子
// T 类型在 unique 函数中需重载 == 运算符// 在 lower_bound 函数中需重载 < 运算符struct T {};bool operator<(const T &a, const T &b);bool operator==(const T &a, const T &b);vector<T> sand;sand.clear();sort(sand.begin(), sand.end());sand.erase(unique(sand.begin(), sand.end()), sand.end());x = lower_bound(sand.begin(), sand.end(), T()) - sand.begin();
ostream& operator<<(ostream &out, LL x) {if (x == 0) {return out << "0";}if(x < 0) {out << "-";x = -x;}static int sta[100];int top = 0;memset(sta, 0, sizeof(sta));while(x != 0) {sta[top++] = x % 10;x /= 10;}for(int i = top - 1; i >= 0; --i) {out << sta[i];}return out;}
| 函数 | 功能 |
|---|---|
| b.any() | b 中是否存在1 |
| b.count() | b 中1的个数 |
| b.size() | b 的二进制位个数 |
| b[pos] | b 在pos 处的二进制位(从低到高) |
| b.reset() | b 的所有二进制位都置零 |
| b.to_ulong() | 返回b 的unsigned long 值 |
| ~b | b 按位取反 |
| b1 | b2 | 按位或 |
| b1 & b2 | 按位与 |
| b << n (b >> n) | b 按位左移(右移)n位 |
对于一张给定的 图,给定 个起点和 个终点,如果从起点 到终点 的路径数为 ,则从任意一个起点到任意一个终点的两条路径不相交的方案数为行列式:
void split(string str, string spacer, vector<string> &ret) {int pos1, pos2;int len = spacer.length();pos1 = 0;pos2 = str.find(spacer);while (pos2 != string::npos) {ret.push_back(str.substr(pos1, pos2 - pos1));pos1 = pos2 + len;pos2 = str.find(spacer, pos1);}if (pos1 != str.length()) {ret.push_back(str.substr(pos1));}}
string intToString(LL x) {string str;if (x == 0) {return "0";}while (x != 0) {str.push_back(x % 10 + '0');x /= 10;}return reverse(str.begin(), str.end());return str;}
