摘要:
LCA 倍增 #include <bits/stdc++.h> using namespace std; const int N = 1e3 + 10; int T; int n, m; int h[N], e[N * 2], ne[N * 2]; // f 为倍增函数,存储每个节点i,取j次父节点 阅读全文
摘要:
乘法原理 每个小数后面相乘的0,在结果的积中是不变的。 #include <bits/stdc++.h> using namespace std; int n, m; int ans; int main() { while (scanf("%d %d", &n, &m)) { ans = 0; if 阅读全文
摘要:
链表模拟 + 队列模拟 可以用队列模拟,维护未弹出的数据和顺序。 也可以直接按题目要求维护循环队列,只需要单链表就够了。 队列: #include <bits/stdc++.h> using namespace std; const int N = 60; int T; int n; int ne[ 阅读全文
摘要:
类LCA问题 采用LCA思想,因为满二叉树的父子之间的大小关系确定了,所以不需要建图,直接用 /2 模拟追溯祖先的过程即可。 #include <bits/stdc++.h> using namespace std; int a, b; int main() { //cout << "pause" 阅读全文