跳到正文

个人记录

注意事项

面条小王子约 3 分钟
原文

这是 2026年10月9日 存档的第 2 版,不是当前版本。查看当前版本

文章信息与版本

文章信息

发布
2025年10月29日
收录
2025年12月12日
更新
2026年11月14日
篇幅
约 3 分钟

版本

  1. v3当前
  2. v2
  3. v1

2026.9.29

快速幂 10 mod 1=01^0 \bmod 1 = 0 !!!

2026.7.12

交互题一定要换行

2026.7.6

当你写下

C++
void f()
{
	static int cnt = 0;
}

多次调用函数 f,cnt不会清空

C++
void f()
{
	static int cnt;
	cnt = 0;
}

这样才可以

2026-4-10

哈希函数

C++
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, aa 和 ajaj 会相同

2025-11-15

函数是要有返回值的

2025-10-29

关于set/map存结构体

重载运算符写完整

这段代码输出 11

C++
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;
}

这段代码输出 22

C++
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;
}

这段代码输出 11

C++
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;
}

这段代码输出 00

C++
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;
}