PAT 三月 29, 2020

PAT甲级 1101 Quick Sort (25分)

文章字数 4k 阅读约需 4 mins. 阅读次数 -

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 distinct positive integers after a run of partition, could you tell how many elements could be the selected pivot for this partition?

For example, given N=5 and the numbers 1, 3, 2, 4, and 5. We have:

  • 1 could be the pivot since there is no element...
查看全文

PAT 三月 29, 2020

PAT甲级 1010 Radix (25分)

文章字数 4.7k 阅读约需 4 mins. 阅读次数 -

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 integers N1 and N2, your task is to find the radix of one...

查看全文

PAT 三月 28, 2020

PAT甲级 1085 Perfect Sequence (25分)

文章字数 2.6k 阅读约需 2 mins. 阅读次数 -

Given a sequence of positive integers and another positive integer p. The sequence is said to be a perfect sequence if Mm×p where M and m are the maximum and minimum numbers in the sequence, respectively.

Now given a sequence and a parameter p, you ...

查看全文

PAT 三月 28, 2020

PAT甲级 1038 Recover the Smallest Number (30分)

文章字数 2.3k 阅读约需 2 mins. 阅读次数 -

Given a collection of number segments, you are supposed to recover the smallest number from them. For example, given { 32, 321, 3214, 0229, 87 }, we can recover many numbers such like 32-321-3214-0229-87 or 0229-32-87-321-3214 with respect to different...

查看全文

PAT 三月 27, 2020

PAT甲级 1067 Sort with Swap(0, i) (25分)

文章字数 2.7k 阅读约需 2 mins. 阅读次数 -

Given any permutation of the numbers {0, 1, 2,…, N−1}, it is easy to sort them in increasing order. But what if Swap(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 following...

查看全文

PAT 三月 26, 2020

PAT乙级 1033 旧键盘打字 (20分)

文章字数 2.1k 阅读约需 2 mins. 阅读次数 -

旧键盘上坏了几个键,于是在敲一段文字的时候,对应的字符就不会出现。现在给出应该输入的一段文字、以及坏掉的那些键,打出的结果文字会是怎样?

输入在 2 行中分别给出坏掉的那些键、以及应该输入的文字。其中对应英文字母的坏键以大写给出;每段文字是不超过 $10^5$ 个字符的串。可用的字符包括字母 [a-z, A-Z]、数字 0-9、以及下划线 _(代表空格)、,.-+(代表上档键)。题目保证第 2 行输入的文字串非空。

注意:如果上档键坏掉了,那么大写的英文字母无法被打出。

在一行中输出能够被...

查看全文

PAT 三月 22, 2020

PAT甲级 1033 To Fill or Not to Fill (25分)

文章字数 5.4k 阅读约需 5 mins. 阅读次数 -

With highways available, driving a car from Hangzhou to any other city is easy. But since the tank capacity of a car is limited, we have to find gas stations on the way from time to time. Different gas station may give different price. You are asked ...

查看全文

PAT 三月 22, 2020

PAT甲级 1095 Cars on Campus (30分)

文章字数 6k 阅读约需 5 mins. 阅读次数 -

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 are supposed to tell, at any specific time point, the...

查看全文

PAT 三月 20, 2020

PAT甲级 1016 Phone Bills (25分)

文章字数 6.2k 阅读约需 6 mins. 阅读次数 -

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

查看全文

PAT 三月 20, 2020

PAT甲级 1012 The Best Rank (25分)

文章字数 5k 阅读约需 5 mins. 阅读次数 -

To evaluate the performance of our first year CS majored students, we consider their grades of three courses only: C - C Programming Language, M - Mathematics (Calculus or Linear Algrbra), and E - English. At the mean time, we encourage students by emphasizing...

查看全文
加载更多
0%