上机
文章平均质量分 76
一些之前上机题目的回忆,以及刷题记录
owlmo
图形学,虚拟现实
展开
-
北航2021复试上机试题(第二题)
一个三叉树的模拟,北航之前的推免,以及19年的上机也有考到三叉树,可以重点看看。 【问题描述】 假设某机场所有登机口(Gate)呈树形排列(树的度为3),安检处为树的根,如下图所示。图中的分叉结点(编号大于等于100)表示分叉路口,登机口用小于100的编号表示(其一定是一个叶结点)。通过对机场所有出发航班的日志分析,得知每个登机口每天的平均发送旅客流量。作为提升机场服务水平的一个措施,在不改变所有航班相对关系的情况下(即:出发时间不变,原在同一登机口的航班不变),仅改变登机口(例如:将3号登机口改到5号原创 2023-12-27 13:03:23 · 1003 阅读 · 0 评论 -
北航2021复试上机试题(第一题)
努力了一年多,终于上岸了,在这里列一下复试上机的试题,以及我自己写的答案(样例都过了,但不知道测试点有没有都过)。另外有时间再写一个经验贴,最近几天恢复恢复。。 一、空闲块分配模拟(最优适配方法) 【问题描述】 在操作系统中,空闲存储空间通常以空闲块链表方式组织,每个块包含块起始位置、块长度及一个指向下一块的指针。空闲块按照存储位置升序组织,最后一块指向第一块(构成循环链表)。当有空间申请请求时,按照如下原则在空闲块循环链表中寻找并分配空闲块: 1)从当前位置开始遍历空闲块链表(初始是从地址最小的第原创 2023-12-27 13:02:21 · 1079 阅读 · 1 评论 -
三叉树 北航机试题
一、题目描述 一个关于三叉树的题目,小于100的值代表树叶,大于100的值为分支点,建树的过程是水平方向建树。 输入格式: 先输入n,代表有n组数据,接下来n行,输入4个数,第一个数代表根节点,接下来分别代表三个子节点,-1代表子节点不存在,输入的顺序按照层次遍历的次序。接下来,要求寻找叶子节点的最短路径,最短路径是指不经过重复的边。输入方式,首先输入一个值m,代表m行,接下来m行输入m个叶子节点和对应的优先级,要求按优先级输出从上次到达的位置到该节点的最短路径,每条路径的最后一个节点要求输出目标叶子原创 2021-03-08 16:55:39 · 586 阅读 · 2 评论 -
PAT 1007 Maximum Subsequence Sum (25 分) (最大连续子序列和)
一、题目描述 Given a sequence ofKintegers {N1,N2, ...,NK}. A continuous subsequence is defined to be {Ni,Ni+1, ...,Nj} where1≤i≤j≤K. The Maximum Subsequence is the continuous subsequence which has the largest sum of its elements. Fo...原创 2021-03-01 16:04:09 · 192 阅读 · 0 评论 -
蓝桥杯 历届试题 小数第n位
问题描述 我们知道,整数做除法时,有时得到有限小数,有时得到无限循环小数。 如果我们把有限小数的末尾加上无限多个0,它们就有了统一的形式。 本题的任务是:在上面的约定下,求整数除法小数点后的第n位开始的3位数。 输入格式 一行三个整数:a b n,用空格分开。a是被除数,b是除数,n是所求的小数后位置(0<a,b,n<1000000000) 输出格式 一行3位数字,表示:a除以b,小数后第n位开始的3位数字。 样例输入1 1 8 1 样例输出1 125 样例输入2 1 8原创 2021-02-25 00:13:49 · 222 阅读 · 0 评论 -
PAT 1049 Counting Ones (30 分)(数学)
一、题目描述 The task is simple: given any positive integerN, you are supposed to count the total number of 1's in the decimal form of the integers from 1 toN. For example, givenNbeing 12, there are five 1's in 1, 10, 11, and 12. 二、输入 Each input file cont...原创 2021-02-24 18:34:29 · 123 阅读 · 0 评论 -
PAT 1072 Gas Station (30 分) (测试点4,坑)
一、题目描述 A gas station has to be built at such a location that the minimum distance between the station and any of the residential housing is as far away as possible. However it must guarantee that all the houses are in its service range. Now given the map原创 2021-02-22 21:26:20 · 644 阅读 · 1 评论 -
PAT 1067 Sort with Swap(0, i) (25 分)(未使用贪心算法,找环)
一、题目描述 Given any permutation of the numbers {0, 1, 2,...,N−1}, it is easy to sort them in increasing order. But what ifSwap(0, *)is the ONLY operation that is allowed to use? For example, to sort {4, 0, 2, 1, 3} we may apply the swap operations in the ...原创 2021-02-21 23:55:02 · 114 阅读 · 0 评论 -
PAT 1003 Emergency (25 分)(图,Dijkstra算法)
一、题目描述 As an emergency rescue team leader of a city, you are given a special map of your country. The map shows several scattered cities connected by some roads. Amount of rescue teams in each city and the length of each road between any pair of cities ar原创 2021-02-21 18:24:37 · 117 阅读 · 0 评论 -
PAT 1034 Head of a Gang (30 分)(图,并查集,字符串hash)
一、题目描述 One way that the police finds the head of a gang is to check people's phone calls. If there is a phone call betweenAandB, we say thatAandBis related. The weight of a relation is defined to be the total time length of all the phone calls made...原创 2021-02-20 18:11:24 · 92 阅读 · 0 评论 -
PAT 1021 Deepest Root (25 分) (图,不太会)
一、题目描述 A graph which is connected and acyclic can be considered a tree. The height of the tree depends on the selected root. Now you are supposed to find the root that results in a highest tree. Such a root is calledthe deepest root. 二、输入 Each input fi.原创 2021-02-19 23:19:49 · 101 阅读 · 0 评论 -
PAT 1013 Battle Over Cities (25 分)(图遍历)
一、题目描述 It is vitally important to have all the cities connected by highways in a war. If a city is occupied by the enemy, all the highways from/toward that city are closed. We must know immediately if we need to repair any other highways to keep the rest原创 2021-02-19 15:18:13 · 118 阅读 · 0 评论 -
PAT 1016 Phone Bills (25 分)(排序)
一、题目描述 A long-distance telephone company charges its customers by the following rules: Making a long-distance call costs a certain amount per minute, depending on the time of day when the call is made. When a customer starts connecting a long-distance ca原创 2021-02-18 11:10:50 · 137 阅读 · 0 评论 -
PAT 1036 Boys vs Girls (25 分)(不难,注意字符串的拷贝)
一、题目描述 This time you are asked to tell the difference between the lowest grade of all the male students and the highest grade of all the female students. 二、输入 Each input file contains one test case. Each case contains a positive integerN, followed byN..原创 2021-02-17 17:58:52 · 158 阅读 · 0 评论 -
PAT 1098 Insertion or Heap Sort (25 分)(堆)
一、题目描述 According to Wikipedia: Insertion sortiterates, consuming one input element each repetition, and growing a sorted output list. Each iteration, insertion sort removes one element from the input data, finds the location it belongs within the sorted.原创 2021-02-17 16:27:12 · 163 阅读 · 0 评论 -
PAT 1107 Social Clusters (30 分)(并查集)
一、题目描述 When register on a social network, you are always asked to specify your hobbies in order to find some potential friends with the same hobbies. Asocial clusteris a set of people who have some of their hobbies in common. You are supposed to find al..原创 2021-02-15 20:56:36 · 106 阅读 · 0 评论 -
PAT 1066 Root of AVL Tree (25 分)(AVL树的简单运用)
一、题目描述 An AVL tree is a self-balancing binary search tree. In an AVL tree, the heights of the two child subtrees of any node differ by at most one; if at any time they differ by more than one, rebalancing is done to restore this property. Figures 1-4 illu原创 2021-02-15 16:47:43 · 232 阅读 · 0 评论 -
PAT 1099 Build A Binary Search Tree (30 分)(二叉搜索树)
一、题目描述 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 gr原创 2021-02-15 12:31:57 · 212 阅读 · 0 评论 -
PAT 1064 Complete Binary Search Tree (30 分)(二叉搜索树)
一、题目描述 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 gr原创 2021-02-15 12:19:01 · 178 阅读 · 0 评论 -
PAT 1065 A+B and C (64bit) (20 分)(舍近求远,大整数运算)
一、题目描述 Given three integersA,BandCin [−2^63,2^63], you are supposed to tell whetherA+B>C. 二、输入 For each test case, output in one lineCase #X: trueifA+B>C, orCase #X: falseotherwise, whereXis the case number (starting from 1). 三...原创 2021-02-15 11:59:19 · 122 阅读 · 0 评论