随笔分类 - PAT(A level)
浙大PAT 甲级题目解答,持续更新。
摘要:反转二叉树就是左右节点互换层遍历使用队列实现中序遍历递归实现The following is from Max Howell @twitter:Google: 90% of our engineers use the software you wrote (Homebrew), but you can't invert a binary tree on a whiteboard so fuck o...
阅读全文
摘要:递归算法,最后为了全部通过用了一些奇技淫巧。。。时间限制1200 ms内存限制65536 kB代码长度限制16000 B判题程序Standard作者CHEN, YueThe K-P factorization of a positive integer N is to write N as the sum of the P-th power of K positive integers. You ...
阅读全文
摘要:People on Mars count their numbers with base 13:Zero on Earth is called "tret" on Mars.The numbers 1 to 12 on Earch is called "jan, feb, mar, apr, may, jun, jly, aug, sep, oct, nov, dec" on Mars, resp...
阅读全文
摘要:make_heap 和 pop_heap 可以实现建堆的操作。另外要注意插入排序下一次可能和本次相同,要输出直到不同的时候的序列。时间限制100 ms内存限制65536 kB代码长度限制16000 B判题程序Standard作者CHEN, YueAccording to Wikipedia:Insertion sort iterates, consuming one input element e...
阅读全文
摘要:freopen("Text.txt", "r", stdin); 输入输出重定向,神器建立二叉树,注意中序遍历和指针的使用 时间限制100 ms内存限制65536 kB代码长度限制16000 B判题程序Standard作者CHEN, YueA Binary Search Tree (BST) is recursively defined as a binary tree which has the...
阅读全文
摘要:Given a singly linked list L with integer keys, you are supposed to remove the nodes with duplicated absolute values of the keys. That is, for each value K, only the first node of which the value or a...
阅读全文
摘要:n和i要用long long要不然乘着乘着就是负的了时间限制400 ms内存限制65536 kB代码长度限制16000 B判题程序Standard作者CHEN, YueAmong all the factors of a positive integer N, there may exist several consecutive numbers. For example, 630 can be ...
阅读全文
摘要:(模拟题)时间限制220 ms内存限制65536 kB代码长度限制16000 B判题程序Standard作者CHEN, YueZhejiang University has 6 campuses and a lot of gates. From each gate we can collect the in/out times and the plate numbers of the cars c...
阅读全文
摘要:A family hierarchy is usually presented by a pedigree tree where all the nodes on the same level belong to the same generation. Your task is to find the generation with the largest population.Input Sp...
阅读全文
摘要:result moded by 1000000007 就是 cout #include #include using namespace std;int main(void) { string s; cin >> s; long long int p=0, pa=0, pat=0; for (int i = 0; i < s.length(); i++) { if (s[i] == 'P') ...
阅读全文
摘要:Eva would like to make a string of beads with her favorite colors so she went to a small shop to buy some beads. There were many colorful strings of beads. However the owner of the shop would only sel...
阅读全文
摘要:One important factor to identify acute stroke (急性脑卒中) is the volume of the stroke core. Given the results of image analysis in which the core regions are identified in each MRI slice, your job is to c...
阅读全文
摘要:时间限制200 ms内存限制65536 kB代码长度限制16000 B判题程序Standard作者CHEN, YueA supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone involved in moving a product from supplier to ...
阅读全文
摘要:(merge不能更坑。。。。)时间限制200 ms内存限制65536 kB代码长度限制16000 B判题程序Standard作者CHEN, YueAccording to Wikipedia:Insertion sort iterates, consuming one input element each repetition, and growing a sorted output list. ...
阅读全文
摘要:For two rational numbers, your task is to implement the basic arithmetics, that is, to calculate their sum, difference, product and quotient.Input Specification:Each input file contains one test case,...
阅读全文
摘要:时间限制200 ms内存限制65536 kB代码长度限制16000 B判题程序Standard作者CHEN, YueIndeed there are many different tourist routes from our city to Rome. You are supposed to find your clients the route with the least cost whil...
阅读全文
摘要:自己想的比较好的一个算法,时间大大节省时间限制300 ms内存限制65536 kB代码长度限制16000 B判题程序Standard作者CAO, PengGiven a sequence of positive integers and another positive integer p. The sequence is said to be a "perfect sequence" if M ...
阅读全文
摘要:时间限制200 ms内存限制65536 kB代码长度限制16000 B判题程序Standard作者CHEN, Yuepush 的顺序就是二叉树的前序pop的顺序就是二叉树的中序遍历本质上还是考根据这两个顺序建立二叉树,并且进行后序遍历An inorder binary tree traversal can be implemented in a non-recursive way with a s...
阅读全文
摘要:On a broken keyboard, some of the keys are worn out. So when you type some sentences, the characters corresponding to those keys will not appear on screen.Now given a string that you are supposed to t...
阅读全文
摘要:Given a list of N student records with name, ID and grade. You are supposed to sort the records with respect to the grade in non-increasing order, and output those student records of which the grades ...
阅读全文
浙公网安备 33010602011771号