- 博客(263)
- 收藏
- 关注
原创 【PAT】A1148 Werewolf - Simple Version
Werewolf(狼人杀) is a game in which the players are partitioned into two parties: the werewolves and the human beings. Suppose that in a game,player #1 said: “Player #2 is a werewolf.”;player #2 said: ...
2019-09-04 08:06:37
580
原创 【PAT】A1061 Dating【字符串处理】
Sherlock Holmes received a note with some strange strings: Let’s date! 3485djDkxh4hhGE 2984akDfkkkkggEdsb s&hgsfdk d&Hyscvnm. It took him only a minute to figure out that those strange strings...
2019-09-04 08:00:00
483
原创 【PAT】A1111 Online Map【Dijkstra算法】
Input our current position and a destination, an online map can recommend several paths. Now your job is to recommend two paths to your user: one is the shortest, and the other is the fastest. It is g...
2019-09-03 21:21:12
774
原创 【PAT】A1138 Postorder Traversal【树】
Suppose that all the keys in a binary tree are distinct positive integers. Given the preorder and inorder traversal sequences, you are supposed to output the first number of the postorder traversal se...
2019-09-03 21:14:39
610
原创 【PAT】A1143 Lowest Common Ancestor【LCA】
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 t...
2019-09-03 21:06:20
820
原创 【PAT】A1145 Hashing - Average Search Time【hash】
The task of this problem is simple: insert a sequence of distinct positive integers into a hash table first. Then try to find another sequence of integer keys from the table and output the average sea...
2019-09-03 21:01:57
707
原创 【PAT】A1155 Heap Paths【堆的判别】
In computer science, a heap is a specialized tree-based data structure that satisfies the heap property: if P is a parent node of C, then the key (the value) of P is either greater than or equal to (i...
2019-09-03 20:55:23
661
1
原创 【PAT】A1152 Google Recruitment【素数判定】
In July 2004, Google posted on a giant billboard along Highway 101 in Silicon Valley (shown in the picture below) for recruitment. The content is super-simple, a URL consisting of the first 10-digit p...
2019-09-03 20:36:17
441
原创 【PAT】A1150 Travelling Salesman Problem【中国邮递员问题】
The “travelling salesman problem” asks the following question: “Given a list of cities and the distances between each pair of cities, what is the shortest possible route that visits each city and retu...
2019-09-03 20:31:25
803
原创 【PAT】A1154 Vertex Coloring【图】
A proper vertex coloring is a labeling of the graph’s vertices with colors such that no two vertices sharing the same edge have the same color. A coloring using at most k colors is called a (proper) k...
2019-09-03 20:24:44
387
1
原创 【PAT】A1151 LCA in a Binary Tree【LCA】
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.Given any two nodes in a binary tree, you are supposed to find their LCA.Inpu...
2019-09-03 19:50:57
741
原创 【PAT】A1149 Dangerous Goods Packaging【散列】
When shipping goods with containers, we have to be careful not to pack some incompatible goods into the same container, or we might get ourselves in serious trouble. For example, oxidizing agent (氧化剂)...
2019-09-03 19:34:24
789
原创 【PAT】A1153 Decode Registration Card of PAT【排序】
A registration card number of PAT consists of 4 parts:the 1st letter represents the test level, namely, T for the top level, A for advance and B for basic;the 2nd - 4th digits are the test site numb...
2019-09-03 15:26:29
550
原创 【PAT】PAT总结《散列、排序、二分、贪心》
散列这个真的很简单了,就是开个数组存一存。基本都是水题。其实这些题,很多有许多更好的方法,在这些题里使用散列实际上是一种暴力做法,对于输入比较小的题目可行。拿到一道题,我们要思考它是要求不重复,还是求数量相关这些角度来考虑开布尔数组还是实型数组计数。有的题目可能要求按顺序输出,不重复输出,像这类问题我们只需要多开几个布尔数组标记就可解决问题。对于字符串类的题目,我们一般开长度为256的标记数...
2019-09-03 14:14:14
3472
原创 【组合数学】nod1284 2 3 5 7的倍数
给出一个数N,求1至N中,有多少个数不是2 3 5 7的倍数。 例如N = 10,只有1不是2 3 5 7的倍数。输入输入1个数N(1 <= N <= 10^18)。输出输出不是2 3 5 7的倍数的数共有多少。输入样例10输出样例1思路先求被2,3,5,7整除的数的个数,然后拿总数减去即可。下面的代码先求被其中一个数整除的数,但是这样会重复计数(因为有的同时被两个...
2019-09-03 14:11:19
869
原创 【线代】矩阵及其运算
知识点矩阵的定义[《线代》P25]矩阵的加法[《线代》P30]数与矩阵相乘。[《线代》P30]矩阵与矩阵相乘。矩阵乘法不满足交换律。矩阵乘法满足结合律和分配律。[可交换]的定义[《线代》P33]纯量阵的定义[《线代》P33]矩阵的幂的定义[《线代》P33](AB)k!=AkBk(除非A与B可交换)矩阵的转置及四个运算规律。[《线代》P36]对称矩阵的定义和特点。[《线...
2019-09-02 23:03:13
3008
原创 【PAT】PAT总结《数学篇》
概述对于数字处理问题,要注意格式化输出中的位数要求,要注意是否需要补充前导0或者后置0。对于字符串和整型浮点型之间的转化要非常熟悉,这样可以事半功倍。在数字问题中,我们往往方法取出各位数对于一个数字n,进行一次模10操作得到最低位,然后将它除以10,再模就得到次低位,知道n为0。这样就可以得到它的每一位。while (n > 0) { t = n % 10; ...
2019-09-01 17:43:02
3315
原创 【中位数】【快速排序】POJ2388 Who's in the Middle
FJ is surveying his herd to find the most average cow. He wants to know how much milk this ‘median’ cow gives: half of the cows give as much or more than the median; half give as much or less.Given a...
2019-09-01 17:14:30
308
原创 【PAT】A1142 Maximal Clique【团】
A clique is a subset of vertices of an undirected graph such that every two distinct vertices in the clique are adjacent. A maximal clique is a clique that cannot be extended by including one more adj...
2019-09-01 16:00:33
537
原创 【PAT】A1141 PAT Ranking of Institutions【排序】
After each PAT, the PAT Center will announce the ranking of institutions based on their students’ performances. Now you are asked to generate the ranklist.Input Specification:Each input file contain...
2019-09-01 15:51:37
493
原创 【PAT】A1140 Look-and-say Sequence【字符串处理】
Look-and-say sequence is a sequence of integers as the following:D, D1, D111, D113, D11231, D112213111, …where D is in [0, 9] except 1. The (n+1)st number is a kind of description of the nth number....
2019-08-31 09:11:37
963
原创 【PAT】A1026 Table Tennis【快乐模拟】
A table tennis club has N tables available to the public. The tables are numbered from 1 to N. For any pair of players, if there are some tables open when they arrive, they will be assigned to the ava...
2019-08-31 09:02:52
925
原创 【PAT】A1115 Counting Nodes in a BST【树】
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 or equal to the node’s key.Th...
2019-08-31 08:56:49
459
原创 【PAT】PAT总结《语法篇》
I/Oc++cin >>cout << res << endl记忆符号方向即可,endl代表换行符。这两个函数都可以链式操作c函数库stdlibdouble atof(const char *str) 把参数 str 所指向的字符串转换为一个浮点数(类型为 double 型)。int atoi(const char *str)把参数 st...
2019-08-30 20:39:21
3788
原创 【PAT】PAT总结《考前经验贴》
通用规则注意题给的数据量的范围,每一个字段的数据范围,选择合适的数据结构。注意题目给的数据是否都是合法的,如有非法的要过滤或者根据题目要求处理,一般题目会有说明。对于字段比较少的,我倾向于使用数组,这样比较简洁,比如学生如果只有id和成绩这两个字段,会分别用id[]和grade[]表示,而不是写一个student结构体。题目给的编号如果从1开始,为了方便,大部分情况下我倾向于将其映射为从...
2019-08-30 20:39:15
5048
1
原创 【PAT】A1078 Hashing【hash】
The task of this problem is simple: insert a sequence of distinct positive integers into a hash table, and output the positions of the input numbers. The hash function is defined to be H(key)=key%TSiz...
2019-08-29 20:22:30
618
原创 【线代】行列式
知识点二阶线性方程组的求解公式。[《线代》P3]排列的概念和对换的定理及推论。[《线代》P5]行列式、上(下)三角形行列式、对角行列式的定义[《线代》P7]行列式的六个性质及相应推论。[《线代》P8]余子式、代数余子式的定义。[《线代》P15]行列式按行(展开)法则、引理及其推论。[《线代》P16、P17、P21]范德蒙德行列式。[《线代》P18例12]拉普拉斯展开式。[《全书》...
2019-08-29 18:42:18
1210
原创 【PAT】A1114 Family Property【并查集】
This time, you are supposed to help us collect the data for family-owned property. Given each person’s family members, and the estate(房产)info under his/her own name, we need to know the size of each f...
2019-08-29 17:50:16
685
原创 【PAT】A1147 Heaps【堆的判定】
1147 Heaps (30 分)In computer science, a heap is a specialized tree-based data structure that satisfies the heap property: if P is a parent node of C, then the key (the value) of P is either greater t...
2019-08-29 17:38:06
920
原创 【PAT】A1146 Topological Order【拓扑序列的判别】
Given N integers, you are supposed to find the smallest positive integer that is NOT in the given list.Input Specification:Each input file contains one test case. For each case, the first line gives...
2019-08-29 14:57:55
747
原创 【PAT】A1144 The Missing Number【散列】
Given N integers, you are supposed to find the smallest positive integer that is NOT in the given list.Input Specification:Each input file contains one test case. For each case, the first line gives...
2019-08-29 14:48:17
513
原创 【PAT】A1075 PAT Judge【排序】
The ranklist of PAT is generated from the status list, which shows the scores of the submissions. This time you are supposed to generate the ranklist for PAT.Input Specification:Each input file cont...
2019-08-28 11:50:24
389
原创 【PAT】A1065 A+B and C (64bit)【简单模拟】
Given three integers A, B and C in [−2^63 ,2^63], you are supposed to tell whether A+B>C.Input Specification:The first line of the input gives the positive number of test cases, T (≤10). Then...
2019-08-27 20:35:13
954
2
原创 【PAT】PAT总结《模拟篇》
概述这类题一般很简单,重点是看清题目的要求,初始条件(比如初始时电梯在第几层)。题给的输入是否有无效输入。一般涉及到字符串(比如人名)可能需要使用set或者map来去重或者判断这个人是否出现过。关于计算,特别是乘法和除法,要注意类型转换。调度问题A1008 ElevatorA1008 Elevator |水题,模拟一个电梯的调度,给出运行速度和停留时间,按照题给的执行序列模拟即可。最...
2019-08-27 11:22:46
3788
原创 【PAT】A1036 Boys vs Girls【最大/最小值】
Input Specification:Each input file contains one test case. Each case contains a positive integer N, followed by N lines of student information. Each line contains a student’s name, gender, ID and gr...
2019-08-25 20:04:34
148
原创 【PAT】A1136 A Delayed Palindrome【大整数相加】
Consider a positive integer N written in standard notation with k+1 digits ai as ak ⋯a1 a0 with 0≤ai <10 for all i and ak >0. Then N is palindromic if and only if ai =ak−...
2019-08-24 18:56:06
666
原创 【PAT】A1135 Is It A Red-Black Tree 【树】
There is a kind of balanced binary search tree named red-black tree in the data structure. It has the following 5 properties:(1) Every node is either red or black.(2) The root is black.(3) Every le...
2019-08-24 18:49:08
702
原创 【PAT】A1134 Vertex Cover【最小顶点覆盖】
A vertex cover of a graph is a set of vertices such that each edge of the graph is incident to at least one vertex of the set. Now given a graph with several vertex sets, you are supposed to tell if e...
2019-08-24 18:34:05
866
原创 【PAT】A1133 Splitting A Linked List【链表】
Given a singly linked list, you are supposed to rearrange its elements so that all the negative values appear before all of the non-negatives, and all the values in [0, K] appear before all those grea...
2019-08-24 10:03:14
566
1
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅