自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(57)
  • 收藏
  • 关注

原创 判断二叉树是否为完全二叉树的两种方法

二叉树的定义struct Node{ int data; int lchild,rchild;} node[30];使用dfs判断是否为完全二叉树void dfs(int root,int index){ if(root==-1) return ; if(index>maxIndex) { maxIndex=index; } dfs(node[root].lchild,index*2); d

2020-05-24 21:40:57 1304

原创 1110 Complete Binary Tree (25分)

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, the first line gives a positive integer N (≤20) which is the total number of nodes in the tree – and hence

2020-05-23 21:39:33 173

原创 1079 Total Sales of Supply Chain (25分)

A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone involved in moving a product from supplier to customer.Starting from one root supplier, everyone on the chain buys products from one’s supplier in a price P a

2020-05-22 22:33:06 173

原创 1090 Highest Price in Supply Chain (25分)

A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone involved in moving a product from supplier to customer.Starting from one root supplier, everyone on the chain buys products from one’s supplier in a price P a

2020-05-22 21:26:58 164

原创 1106 Lowest Price in Supply Chain (25分)

A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone involved in moving a product from supplier to customer.Starting from one root supplier, everyone on the chain buys products from one’s supplier in a price P a

2020-05-22 21:20:02 138

原创 1101 Quick Sort (25分)

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 the elements less than the pivot are moved to its left and those larger than the pivot to its right. Given N

2020-05-18 22:22:51 94

原创 1022 Digital Library (30分)

A Digital Library contains millions of books, stored according to their titles, authors, key words of their abstracts, publishers, and published years. Each book is assigned an unique 7-digit number as its ID. Given any query from a reader, you are suppose

2020-05-18 20:49:37 140

原创 1145 Hashing - Average Search Time (25分)

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 search time (the number of comparisons made to find whether

2020-05-17 21:28:36 165

原创 1078 Hashing (25分)

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%TSize where TSize is the maximum size of the hash table. Qua

2020-05-17 20:45:11 163

原创 1133 Splitting A Linked List (25分)

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 greater than K. The order of the elements inside each class

2020-05-16 21:23:06 118

原创 1094 The Largest Generation (25分)

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 Specification:Each input file contains one test case. E

2020-05-16 20:16:58 137

原创 1074 Reversing Linked List (25分)

Given a constant K and a singly linked list L, you are supposed to reverse the links of every K elements on L. For example, given L being 1→2→3→4→5→6, if K=3, then you must output 3→2→1→6→5→4; if K=4, you must output 4→3→2→1→5→6.Input Specification:Each

2020-05-16 19:24:01 163

原创 1042 Shuffling Machine (20分)

Shufling is a procedure used to randomize a deck of playing cards. Because standard shuflingtechniques are seen as weak, and in order to avoid “inside jobs” where employees collaborate withgamblers by performing inadequate shufles, many casinos employ au

2020-05-09 21:38:34 175

原创 1140 Look-and-say Sequence (20分)

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 nu...

2020-04-25 22:15:58 120

原创 1112 Stucked Keyboard (20分)

On a broken keyboard, some of the keys are always stucked. So when you type some sentences, the characters corresponding to those keys will appear repeatedly on screen for k times.Now given a result...

2020-04-23 22:36:47 124

原创 1061 Dating (20分)

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...

2020-04-10 23:08:31 134

原创 1019 General Palindromic Number (20分)

A number that will be the same when it is written forwards or backwards is known as a PalindromicNumber. For example, 1234321 is a palindromicnumber. All single digit numbers are palindromicnumbers.Al...

2020-03-20 22:50:31 132

原创 1058 A+B in Hogwarts (20分)

If you are a fan of Harry Potter, you would know the world of magic has its own currency system – as Hagrid explained it to Harry, “Seventeen silver Sickles to a Galleon and twenty-nine Knuts to a Sic...

2020-03-20 22:44:57 132

原创 1010 Radix (25分)

Given a pair of positive integers, for example, 6 and 110, can this equation 6 = 110 be true? The answer is yes, if 6 is a decimal number and 110 is a binary number.Now for any pair of positive integ...

2020-03-20 22:40:36 136

原创 1015 Reversible Primes (20分)

A reversible prime in any number system is a prime whose “reverse” in that number system is also a prime. For example in the decimal system 73 is a reversible prime because its reverse 37 is also a pr...

2020-03-18 23:12:26 114

原创 1027 Colors in Mars (20分)

People in Mars represent the colors in their computers in a similar way as the Earth people. That is, a color is represented by a 6-digit number, where the first 2 digits are for Red, the middle 2 dig...

2020-03-18 23:08:24 104

原创 1096 Consecutive Factors (20分)

Among all the factors of a positive integer N, there may exist several consecutive numbers. For example, 630 can be factored as 3×5×6×7, where 5, 6, and 7 are the three consecutive numbers. Now given ...

2020-03-15 22:52:11 147

原创 1152 Google Recruitment (20分)

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...

2020-03-15 18:35:08 101

原创 1059 Prime Factors (25分)

Given any positive integer N, you are supposed to find all of its prime factors, and write them in the format N = p​1​​​k​1​​​​×p​2​​​k​2​​​​×⋯×p​m​​​^k​m​​​​.Input Specification:Each input file co...

2020-03-15 18:22:15 183

原创 1069 The Black Hole of Numbers (20分)

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-decreasing order, a new number can be obtained by takin...

2020-03-15 18:08:41 149

原创 1116 Come on! Let's C (20分)

“Let’s C” is a popular and fun programming contest hosted by the College of Computer Science and Technology, Zhejiang University. Since the idea of the contest is for fun, the award rules are funny as...

2020-03-14 23:17:02 120

原创 1035 Password (20分)

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 since it is hard to distinguish 1 (one) from l (L ...

2020-03-10 23:16:23 118

原创 1066 Root of AVL Tree (25分)

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...

2020-03-10 21:31:49 163

原创 1123 Is It a Complete AVL Tree (30分)

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...

2020-03-09 22:43:01 105

原创 1155 Heap Paths (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 than or equal to (i...

2020-03-05 23:30:42 135

原创 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 than or equal to (i...

2020-03-05 21:29:19 133

原创 1098 Insertion or Heap Sort (25分)

According to Wikipedia:Insertion sort iterates, consuming one input element each repetition, and growing a sorted output list. Each iteration, insertion sort removes one element from the input data, ...

2020-03-04 21:35:06 106

原创 1153 Decode Registration Card of PAT (25分)

A registration card number of PAT consists of 4 parts:the 1st letter represents the test level, namely, T for the toplevel, A for advance and B for basic;the 2nd - 4th digits are the test site num...

2020-03-01 20:09:58 143

原创 1055 The World's Richest (25分)

Forbes magazine publishes every year its list of billionaires based on the annual ranking of the world’s wealthiest people. Now you are supposed to simulate this job, but concentrate only on the peopl...

2020-02-28 23:07:18 121

原创 1080 Graduate Admission (30分)

It is said that in 2011, there are about 100 graduate schools ready to proceed over 40,000 applications in Zhejiang Province. It would help a lot if you could write a program to automate the admission...

2020-02-28 22:37:33 115

原创 1117 Eddington Number (25分)

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 – that is, the maximum integer E such that it is for E d...

2020-02-26 23:16:16 127

原创 1141 PAT Ranking of Institutions (25分)

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 contai...

2020-02-26 21:59:23 1028

原创 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 ...

2020-02-24 23:01:48 151

原创 1095 Cars on Campus (30分)

Zhejiang University has 8 campuses and a lot of gates. From each gate we can collect the in/out times and the plate numbers of the cars crossing the gate. Now with all the information available, you a...

2020-02-22 22:00:51 141

原创 1025 PAT Ranking (25分)

Programming Ability Test (PAT) is organized by the College of Computer Science and Technology of Zhejiang University. Each test is supposed to run simultaneously in several places, and the ranklists w...

2020-02-20 22:24:33 104

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除