之前使用Magic trackpad 2时候出了点小问题,发现断开trackpad后依然无法使用内建触控板,导致自己用了一天的鼠标ORZ……然后就想到了能否两个触控板一起使用的功能……果然在辅助功能里面有~(不过似乎朋友的MacBook里这个功能是默认关闭的,不知道为什么我的是默认打开的…)
所以这个问题也可以解决:蓝牙触控板Magic trackpad断开连接后原触控板依然无法使用的问题
系统偏好设置 – 辅助功能 – 鼠标与触控板 – 取消勾选“有鼠标或无线触控板时忽略内建触控板”
你可不可以
成为我的main函数
做我此生必须有
且只能有一个的入口
——————————
我愿为自己加上private
在你的class中只有
你能调用
——————————————代 码 如 诗 。
之前使用Magic trackpad 2时候出了点小问题,发现断开trackpad后依然无法使用内建触控板,导致自己用了一天的鼠标ORZ……然后就想到了能否两个触控板一起使用的功能……果然在辅助功能里面有~(不过似乎朋友的MacBook里这个功能是默认关闭的,不知道为什么我的是默认打开的…)
所以这个问题也可以解决:蓝牙触控板Magic trackpad断开连接后原触控板依然无法使用的问题
系统偏好设置 – 辅助功能 – 鼠标与触控板 – 取消勾选“有鼠标或无线触控板时忽略内建触控板”
The lowest common ancestor (LCA) of two nodes U and V in a tree is the deepest node that has both U and V as descendants.
A binary search tree (BST) is recursively defined as a binary tree which has the following properties:
The left subtree of a node contains only nodes with keys less than the node’s key.
The right subtree of a node contains only nodes with keys greater than or equal to the node’s key.
Both the left and right subtrees must also be binary search trees.
Given any two nodes in a BST, you are supposed to find their LCA.
Input Specification:
Each input file contains one test case. For each case, the first line gives two positive integers: M (<= 1000), the number of pairs of nodes to be tested; and N (<= 10000), the number of keys in the BST, respectively. In the second line, N distinct integers are given as the preorder traversal sequence of the BST. Then M lines follow, each contains a pair of integer keys U and V. All the keys are in the range of int.
Output Specification:
For each given pair of U and V, print in a line “LCA of U and V is A.” if the LCA is found and A is the key. But if A is one of U and V, print “X is an ancestor of Y.” where X is A and Y is the other node. If U or V is not found in the BST, print in a line “ERROR: U is not found.” or “ERROR: V is not found.” or “ERROR: U and V are not found.”.
Sample Input:
6 8
6 3 1 2 5 4 8 7
2 5
8 7
1 9
12 -3
0 8
99 99
Sample Output:
LCA of 2 and 5 is 3.
8 is an ancestor of 7.
ERROR: 9 is not found.
ERROR: 12 and -3 are not found.
ERROR: 0 is not found.
ERROR: 99 and 99 are not found.
题目大意:给出一棵二叉搜索树的前序遍历,问结点u和v的共同最低祖先是谁~
分析:map<int, bool> mp用来标记树中所有出现过的结点,遍历一遍pre数组,将当前结点标记为a,如果u和v分别在a的左、右,或者u、v其中一个就是当前a,即(a >= u && a <= v) || (a >= v && a <= u),说明找到了这个共同最低祖先a,退出当前循环~最后根据要求输出结果即可~
PS:30分的题目30行代码解决,1行1分,惊不惊喜?意不意外?(真的是水题啊…)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
#include <iostream> #include <vector> #include <map> using namespace std; map<int, bool> mp; int main() { int m, n, u, v, a; scanf("%d %d", &m, &n); vector<int> pre(n); for (int i = 0; i < n; i++) { scanf("%d", &pre[i]); mp[pre[i]] = true; } for (int i = 0; i < m; i++) { scanf("%d %d", &u, &v); for(int j = 0; j < n; j++) { a = pre[j]; if ((a >= u && a <= v) || (a >= v && a <= u)) break; } if (mp[u] == false && mp[v] == false) printf("ERROR: %d and %d are not found.\n", u, v); else if (mp[u] == false || mp[v] == false) printf("ERROR: %d is not found.\n", mp[u] == false ? u : v); else if (a == u || a == v) printf("%d is an ancestor of %d.\n", a, a == u ? v : u); else printf("LCA of %d and %d is %d.\n", u, v, a); } return 0; } |
This is a problem given in the Graduate Entrance Exam in 2018: Which of the following is NOT a topological order obtained from the given directed graph? Now you are supposed to write a program to test each of the options.
Input Specification:
Each input file contains one test case. For each case, the first line gives two positive integers N (<= 1,000), the number of vertices in the graph, and M (<= 10,000), the number of directed edges. Then M lines follow, each gives the start and the end vertices of an edge. The vertices are numbered from 1 to N. After the graph, there is another positive integer K (<= 100). Then K lines of query follow, each gives a permutation of all the vertices. All the numbers in a line are separated by a space.
Output Specification:
Print in a line all the indices of queries which correspond to “NOT a topological order”. The indices start from zero. All the numbers are separated by a space, and there must no extra space at the beginning or the end of the line. It is graranteed that there is at least one answer.
Sample Input:
6 8
1 2
1 3
5 2
5 4
2 3
2 6
3 4
6 4
5
1 5 2 3 6 4
5 1 2 6 3 4
5 1 2 3 6 4
5 2 1 6 3 4
1 2 3 4 5 6
Sample Output:
3 4
题目大意:给一个有向图,判断给定序列是否是拓扑序列~
分析:用邻接表v存储这个有向图,并将每个节点的入度保存在in数组中。对每一个要判断是否是拓扑序列的结点遍历,如果当前结点的入度不为0则表示不是拓扑序列,每次选中某个点后要将它所指向的所有结点的入度-1,最后根据是否出现过入度不为0的点决定是否要输出当前的编号i~flag是用来判断之前是否输出过现在是否要输出空格的~judge是用来判断是否是拓扑序列的~
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
#include <iostream> #include <vector> using namespace std; int main() { int n, m, a, b, k, flag = 0, in[1010]; vector<int> v[1010]; scanf("%d %d", &n, &m); for (int i = 0; i < m; i++) { scanf("%d %d", &a, &b); v[a].push_back(b); in[b]++; } scanf("%d", &k); for (int i = 0; i < k; i++) { int judge = 1; vector<int> tin(in, in+n+1); for (int j = 0; j < n; j++) { scanf("%d", &a); if (tin[a] != 0) judge = 0; for (int it : v[a]) tin[it]--; } if (judge == 1) continue; printf("%s%d", flag == 1 ? " ": "", i); flag = 1; } return 0; } |
使用homebrew安装rar(没安装homebrew的要先装一下下)
brew install caskroom/cask/rar
安装完成后先切到想要解压到的目录,然后使用解压功能:(xxx.rar是某个rar文件,要写它的路径在哪,可以直接从文件夹拖到命令行里面自动生成它的路径)
rar x xxx.rar
近来出门都是ipad上用多看阅读、kindle、豆瓣阅读之类的app看电子书,多看的导出印象笔记功能不错,但是有的书多看阅读上没有,epub格式的也找不到(为了能够标注里面的文字做笔记),所以只能用kindle app看,结果发现导出笔记时候提示“未设置电子邮箱账户”,需要以下设置:
1 2 3 4 5 |
第一部分 价格与市场 标注(粉色) - 02.饭店为何要收开瓶费 > 位置 324 许多餐馆对自带酒水者收取开瓶费,是因为他们刻意压低了饭菜的毛利而抬高了酒水的毛利,以此对喝酒和不喝酒的客户实施差别定价。这一策略让他们既能吸引那些只是想吃顿便饭的、预算较拮据的、善于精打细算的客户,又能从那些亲友聚餐、商务宴请、有幸垂顾的大款等消费意愿强烈、价格承受能力较高的客户那里,挣得尽可能多的收入。 标注(粉色) - 02.饭店为何要收开瓶费 > 位置 330 实际上,对于许多饭店,尽管酒水只占其销售额的 20% ~ 30%,但常常要贡献 50% ~ 60%的毛利;而从消费者的角度看,这其实是在让喝酒客户补贴不喝酒或少喝酒的客户。 |