2026.11.1
INF 的数不要太大(除非你特判严格)
否则加几个数就溢出
long long MAX = 0x7fffffffffffffff
INF 可以设 0x7f7f7f7f7f7f7f7f
他们相差 0x0080808080808080 即 36170086419038336
2026.10.29
整数除法是向 0 取整
例如
并且 floor ceil 函数要内部是double才可以正确处理
例如
2026.10.26
字符 转换成编号 ,可以
但 大写字母 和 小写字母不行
本质上 48 = 110000
发现 0~9 二进制只有 4 位异或不影响
2026.9.29
快速幂 !!!
2026.7.12
2026.7.6
当你写下
void f()
{
static int cnt = 0;
}多次调用函数 f,cnt不会清空
void f()
{
static int cnt;
cnt = 0;
}这样才可以
2026-4-10
哈希函数
for (register int i = 1; i <= len; ++ i) powB[i] = 1ll * powB[i - 1] * B % P, H[i] = (1ll * H[i - 1] * B % P + str[i] - 'a') % P;上式子是错的
str[i] - 'a' 不能为 0
如果为0, 和 会相同
2025-11-15
2025-10-29
关于set/map存结构体
重载运算符写完整
这段代码输出
struct node
{
int cnt, id;
bool operator< (const node &t)const
{
return cnt > t.cnt;
}
};
set<node> tong;
int main()
{
tong.insert({1, 5});
tong.insert({1, 6});
cout << tong.size();
return 0;
}这段代码输出
struct node
{
int cnt, id;
bool operator< (const node &t)const
{
if (cnt == t.cnt) return id > t.id;
return cnt > t.cnt;
}
};
set<node> tong;
int main()
{
tong.insert({1, 5});
tong.insert({1, 6});
cout << tong.size();
return 0;
}这段代码输出
struct node
{
int cnt, id;
bool operator< (const node &t)const
{
return cnt > t.cnt;
}
};
map<node, int> tong;
int main()
{
tong[{1, 5}] = 1;
cout << tong[{1, 6}];
return 0;
}这段代码输出
struct node
{
int cnt, id;
bool operator< (const node &t)const
{
if (cnt == t.cnt) return id > t.id;
return cnt > t.cnt;
}
};
map<node, int> tong;
int main()
{
tong[{1, 5}] = 1;
cout << tong[{1, 6}];
return 0;
}