02 2021 档案
摘要: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. Inp
阅读全文
摘要:Given a set of N (>) positive integers, you are supposed to partition them into two disjoint sets A1 and A2 of n1 and n2 numbers, respecti
阅读全文
摘要:Recommendation system predicts the preference that a user would give to an item. Now you are asked to program a very simple recommendation system that
阅读全文
摘要:British astronomer Eddington liked to ride a bike. It is said that in order to show off his skill, he has even defined an "Eddington number", E -- tha
阅读全文
摘要:Programming Ability Test (PAT) is organized by the College of Computer Science and Technology of Zhejiang University. Each test is supposed to run sim
阅读全文
摘要:About 900 years ago, a Chinese philosopher Sima Guang wrote a history book in which he talked about people's talent and virtue. According to his theor
阅读全文
摘要: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
阅读全文
摘要: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 s
阅读全文
摘要:"Damn Single (单身狗)" is the Chinese nickname for someone who is being single. You are supposed to find those who are alone in a big party, so they can
阅读全文
摘要:Two integers are called "friend numbers" if they share the same sum of their digits, and the sum is their "friend ID". For example, 123 and 51 are fri
阅读全文
摘要: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 sc
阅读全文
摘要: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 b
阅读全文
摘要:Eva loves to collect coins from all over the universe, including some other planets like Mars. One day she visited a universal shopping mall which cou
阅读全文
摘要:People often have a preference among synonyms of the same word. For example, some may prefer "the police", while others may prefer "the cops". Analyzi
阅读全文
摘要:Given two sets of integers, the similarity of the sets is defined to be /, where Nc is the number of distinct common numbers shared by the two sets
阅读全文
摘要: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. A socia
阅读全文
摘要:Some scientists took pictures of thousands of birds in a forest. Assume that all the birds appear in the same picture belong to the same tree. You are
阅读全文
摘要:One way that the police finds the head of a gang is to check people's phone calls. If there is a phone call between A and B, we say that A and B is re
阅读全文
摘要: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
阅读全文
摘要: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 t
阅读全文
摘要:Indeed there are many different tourist routes from our city to Rome. You are supposed to find your clients the route with the least cost while gainin
阅读全文
摘要: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 po
阅读全文
摘要:For any 4-digit integer except the ones with all the digits being the same, if we sort the digits in non-increasing order first, and then in non-decre
阅读全文
摘要: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
阅读全文
摘要:Suppose that all the keys in a binary tree are distinct positive integers. Given the preorder and inorder traversal sequences, you are supposed to out
阅读全文
摘要:#include<bits/stdc++.h> using namespace std; vector<int> pre,post,in; void toPost(int root,int inL,int inR){ if(inL>inR){ return ; } // int k=inL; int
阅读全文
摘要:Given a syntax tree (binary), you are supposed to output the corresponding infix expression, with parentheses reflecting the precedences of the operat
阅读全文
摘要:假设二叉树中的所有键都是不同的正整数。可以通过给定的一对后序遍历和有序遍历序列来确定唯一的二叉树。这是一个简单的标准例程,可以按级别顺序打印数字。但是,如果您认为问题太简单了,那就太天真了。这次,您应该按“曲折顺序”打印数字-也就是说,从根开始,逐级打印数字,从左到右和从右到左交替。例如,对于以下树
阅读全文
摘要:Given a tree, you are supposed to tell if it is a complete binary tree. Input Specification: Each input file contains one test case. For each case, th
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要:Suppose that all the keys in a binary tree are distinct positive integers. A unique binary tree can be determined by a given pair of postorder and ino
阅读全文
摘要: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
阅读全文
摘要:A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone involved in moving a product from supplier to customer
阅读全文
摘要: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 t
阅读全文
摘要:A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone involved in moving a product from supplier to customer
阅读全文
摘要:一:由先序和中序,确定后序 post(0,0,n-1); void toPost(int root,int left,int right){//root为先序中根节点的下标,left和right分别为中序中子树的左右边界 if(left>right){ return ; } int i=left;
阅读全文
摘要:An inorder binary tree traversal can be implemented in a non-recursive way with a stack. For example, suppose that when a 6-node binary tree (with the
阅读全文
摘要:A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone involved in moving a product from supplier to customer
阅读全文
摘要:Given a non-empty tree with root R, and with weight Wi assigned to each tree node Ti. The weight of a path from R to L is defined to be the sum
阅读全文
摘要:Weibo is known as the Chinese version of Twitter. One user on Weibo may have many followers, and may follow many other users as well. Hence a social n
阅读全文
摘要: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 po
阅读全文
摘要: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
阅读全文
摘要:The "travelling salesman problem" asks the following question: "Given a list of cities and the distances between each pair of cities, what is the shor
阅读全文
摘要:1.cin和cout消耗的时间比scanf和printf多得多,建议用后者 2.memset不能对数组进行任意初始化,只能初始化为-1,0 3.初始化一般用fill 一维数组:fill (array,array+4,5); vector容器:fill (myvector.begin(),myvect
阅读全文
摘要:There is a classical process named partition in the famous quick sort algorithm. In this process we typically choose one element as the pivot. Then th
阅读全文
摘要:After each PAT, the PAT Center will announce the ranking of institutions based on their students' performances. Now you are asked to generate the rank
阅读全文
摘要: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 inte
阅读全文
摘要:Given a sequence of positive numbers, a segment is defined to be a consecutive subsequence. For example, given the sequence { 0.1, 0.2, 0.3, 0.4 }, we
阅读全文
摘要: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
阅读全文
摘要:Cutting an integer means to cut a K digits lone integer Z into two integers of (K/2) digits long integers A and B. For example, after cutting Z = 1673
阅读全文
摘要:Consider a positive integer N written in standard notation with k+1 digits ai as ak⋯a1a0 with 0 for all i and ak>0. Then N is palindrom
阅读全文
摘要: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)s
阅读全文
摘要:string 转 char* 使用c_str() #include<bits/stdc++.h> using namespace std; int main(){ string s="abc"; printf("%s\n",s.c_str());//string 转 char * return 0;
阅读全文
摘要:Zhejiang University has 40,000 students and provides 2,500 courses. Now given the registered course list of each student, you are supposed to output t
阅读全文
摘要:Zhejiang University has 40000 students and provides 2500 courses. Now given the student name lists of all the courses, you are supposed to output the
阅读全文
摘要:A Digital Library contains millions of books, stored according to their titles, authors, key words of their abstracts, publishers, and published years
阅读全文
摘要:Shopping in Mars is quite a different experience. The Mars people pay by chained diamonds. Each diamond has a value (in Mars dollars M$). When making
阅读全文
摘要:在return 0前面添加 system("pause"); 可以让程序暂停,防止一闪而过。
阅读全文
摘要:关闭同步,可以提升cin和cout的速度 代码: std::ios::sync_with_stdio(false);
阅读全文
摘要:原因:自定义的****变量与库中重名; 解决:修改一下变量名
阅读全文
摘要: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
阅读全文
摘要:Shuffling is a procedure used to randomize a deck of playing cards. Because standard shuffling techniques are seen as weak, and in order to avoid "ins
阅读全文
摘要:Given a stack which can keep M numbers at most. Push N numbers in the order of 1, 2, 3, ..., N and pop randomly. You are supposed to tell if a given s
阅读全文
摘要:Behind the scenes in the computer's memory, color is always talked about as a series of 24 bits of information for each pixel. In an image, the color
阅读全文
摘要:Being unique is so important to people on Mars that even their lottery is designed in a unique way. The rule of winning is simple: one bets on a numbe
阅读全文
摘要:To store English words, one method is to use linked lists and store a word letter by letter. To save some space, we may let the words share the same s
阅读全文
摘要:To prepare for PAT, the judge sometimes has to generate random passwords for the users. The problem is that there are always some confusing passwords
阅读全文
摘要:Given two strings S1 and S2, S=S1−S2 is defined to be the remaining string after taking all the characters in S2 from S1. Your task
阅读全文
摘要:A traveler's map gives the distances between cities along the highways, together with the cost of each highway. Now you are supposed to write a progra
阅读全文
摘要:Given an increasing sequence S of N integers, the median is the number at the middle position. For example, the median of S1 = { 11, 12, 13, 14 } is 1
阅读全文
摘要:Excel can sort records according to any column. Now you are supposed to imitate this function. Input Specification: Each input file contains one test
阅读全文