自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 PAT A1081 Rational Sum (20 分)

PAT A1081 Rational Sum (20 分)Given N rational numbers in the form numerator/denominator, you are supposed to calculate their sum.Input Specification:Each input file contains one test case. Each case starts with a positive integer N (≤100), followed in t

2021-03-04 18:01:12 168 1

原创 PAT B1008 数组元素循环右移问题 (20 分)

PAT B1008 数组元素循环右移问题 (20 分)一个数组A中存有N(>0)个整数,在不允许使用另外数组的前提下,将每个整数循环向右移M(≥0)个位置,即将A中的数据由(A​0​ A1 ⋯AN−1 )变换为(A​N−M ⋯A​N−1​ A​0 A​1​ ⋯A​N−M−1​ )(最后M个数循环移至最前面的M个位置)。如果需要考虑程序移动数据的次数尽量少,要如何设计移动的方法?输入格式:每个输入包含一个测试用例,第1行输入N(1≤N≤100)和M(≥0);第2行输入N个整数,之间用空格分隔。输

2021-03-01 18:35:58 136

原创 PAT A1049 Counting Ones (30 分)

PAT A1049 Counting Ones (30 分)The task is simple: given any positive integer N, you are supposed to count the total number of 1’s in the decimal form of the integers from 1 to N. For example, given N being 12, there are five 1’s in 1, 10, 11, and 12.Inpu

2021-03-01 18:16:57 129

原创 PAT A1008 Elevator (20 分)

PAT A1008 Elevator (20 分)The highest building in our city has only one elevator. A request list is made up with N positive numbers. The numbers denote at which floors the elevator will stop, in specified order. It costs 6 seconds to move the elevator up o

2021-03-01 16:05:57 127

原创 PAT A1104 Sum of Number Segments (20 分)/B 1049 数列的片段和 (20 分)

PAT A1104 Sum of Number Segments (20 分)/B 1049 数列的片段和 (20 分)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 have 10 segments: (0.1) (0.1, 0.2) (0.1, 0.2

2021-02-28 19:47:25 148 1

原创 PAT A 1069 The Black Hole of Numbers (20 分)/B 1019 数字黑洞 (20 分)

PAT A 1069 The Black Hole of Numbers (20 分)/B 1019 数字黑洞 (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 b

2021-02-28 19:05:13 118

原创 PAT B 1003 我要通过! (20 分)

PAT B 1003 我要通过! (20 分)“答案正确”是自动判题系统给出的最令人欢喜的回复。本题属于 PAT 的“答案正确”大派送 —— 只要读入的字符串满足下列条件,系统就输出“答案正确”,否则输出“答案错误”。得到“答案正确”的条件是:字符串中必须仅有 P、 A、 T这三种字符,不可以包含其它字符;任意形如 xPATx 的字符串都可以获得“答案正确”,其中 x 或者是空字符串,或者是仅由字母 A 组成的字符串;如果 aPbTc 是正确的,那么 aPbATca 也是正确的,其中 a、 b、

2021-02-28 18:45:45 101

原创 PAT A1029 Median (25 分)

PAT A1029 Median (25 分)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 12, and the median of S2 = { 9, 10, 15, 16, 17 } is 15. The median of two sequences

2021-02-26 18:08:21 130

原创 PAT A1089 Insert or Merge (25 分)/B 1035 插入与归并 (25 分)

PAT A1089 Insert or Merge (25 分)/B 1035 插入与归并 (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, fin

2021-02-26 17:40:25 157

原创 PAT A1044 Shopping in Mars (25 分)

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 the payment, the chain can be cut at any position for only once and some of the diamonds are taken off the

2021-02-25 17:27:36 141

原创 PAT A1010 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 integers N​1​​ and N​2​​ , your task is to find the radix of

2021-02-24 18:22:52 159

原创 PAT A1085 Perfect Sequence (25 分)/B 1030 完美数列 (25 分)

PAT A1085 Perfect Sequence (25 分)/B 1030 完美数列 (25 分)Given a sequence of positive integers and another positive integer p. The sequence is said to be a perfect sequence if M≤m×p where M and m are the maximum and minimum numbers in the sequence, respectivel

2021-02-21 19:50:09 146

原创 PAT A1038 Recover the Smallest Number (30 分)

PAT A1038 Recover the Smallest Number (30 分)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

2021-02-21 18:56:55 90

原创 PAT A1067 Sort with Swap(0, i) (25 分)

PAT A1067 Sort with Swap(0, i) (25 分)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

2021-02-21 17:10:21 71

原创 PAT A1037 Magic Coupon (25 分)

PAT A1037 Magic Coupon (25 分)The magic shop in Mars is offering some magic coupons. Each coupon has an integer N printed on it, meaning that when you use this coupon with a product, you may get N times the value of that product back! What is more, the sho

2021-02-20 18:44:48 122

原创 PAT A1033 To Fill or Not to Fill (25 分)

PAT A1033 To Fill or Not to Fill (25 分)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 gi

2021-02-20 17:28:32 113

原创 PAT A1048 Find Coins (25 分)

PAT A1048 Find Coins (25 分)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 could accept all kinds of coins as payments. However, there was a special require

2021-02-20 01:06:31 218

原创 PAT B1005 继续(3n+1)猜想 (25 分)

PAT B1005 继续(3n+1)猜想 (25 分)卡拉兹(Callatz)猜想已经在1001中给出了描述。在这个题目里,情况稍微有些复杂。当我们验证卡拉兹猜想的时候,为了避免重复计算,可以记录下递推过程中遇到的每一个数。例如对 n=3 进行验证的时候,我们需要计算 3、5、8、4、2、1,则当我们对 n=5、8、4、2 进行验证的时候,就可以直接判定卡拉兹猜想的真伪,而不需要重复计算,因为这 4 个数已经在验证3的时候遇到过了,我们称 5、8、4、2 是被 3“覆盖”的数。我们称一个数列中的某个数

2021-02-20 00:25:35 157 2

原创 PAT A1050 String Subtraction (20 分)

PAT A1050 String Subtraction (20 分)Given two strings S​1​​ and S​2​​ , S=S​1​​ −S​2​​ is defined to be the remaining string after taking all the characters in S​2​​ from S​1​​ . Your task is simply to calculate S​1​​ −S​2​​ for any given strings. Howe

2021-02-19 23:22:11 101

原创 PAT A1041 Be Unique (20 分)

PAT A1041 Be Unique (20 分)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 number chosen from [1,10^ ​4​​ ]. The first one who bets on a unique number wins. Fo

2021-02-19 23:13:18 115

原创 PAT B1047 编程团体赛 (20 分)

PAT B1047 编程团体赛 (20 分)编程团体赛的规则为:每个参赛队由若干队员组成;所有队员独立比赛;参赛队的成绩为所有队员的成绩和;成绩最高的队获胜。现给定所有队员的比赛成绩,请你编写程序找出冠军队。输入格式:输入第一行给出一个正整数 N(≤10^ ​4​ ),即所有参赛队员总数。随后 N 行,每行给出一位队员的成绩,格式为:队伍编号-队员编号 成绩,其中队伍编号为 1 到 1000 的正整数,队员编号为 1 到 10 的正整数,成绩为 0 到 100 的整数。输出格式:在一行中输出冠军

2021-02-19 23:04:34 158

原创 PAT B1043 输出PATest (20 分)

PAT B1043 输出PATest (20 分)给定一个长度不超过 10^ ​4​​ 的、仅由英文字母构成的字符串。请将字符重新调整顺序,按 PATestPATest… 这样的顺序输出,并忽略其它字符。当然,六种字符的个数不一定是一样多的,若某种字符已经输出完,则余下的字符仍按 PATest 的顺序打印,直到所有字符都被输出。输入格式:输入在一行中给出一个长度不超过 10^ 4​​ 的、仅由英文字母构成的非空字符串。输出格式:在一行中按题目要求输出排序后的字符串。题目保证输出非空。输入样例

2021-02-19 22:55:47 98

原创 PAT B1042 字符统计 (20 分)

PAT B1042 字符统计 (20 分)请编写程序,找出一段给定文字中出现最频繁的那个英文字母。输入格式:输入在一行中给出一个长度不超过 1000 的字符串。字符串由 ASCII 码表中任意可见字符及空格组成,至少包含 1 个英文字母,以回车结束(回车不算在内)。输出格式:在一行中输出出现频率最高的那个英文字母及其出现次数,其间以空格分隔。如果有并列,则输出按字母序最小的那个字母。统计时不区分大小写,输出小写字母。输入样例:This is a simple TEST. There ARE

2021-02-19 22:33:14 87

原创 PAT A1092 To Buy or Not to Buy (20 分)/B 1039 到底买不买 (20 分)

PAT A1092 To Buy or Not to Buy (20 分)/B 1039 到底买不买 (20 分)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 s

2021-02-19 22:23:19 113

原创 PAT B1038 统计同成绩学生 (20 分)

PAT B1038 统计同成绩学生 (20 分)本题要求读入 N 名学生的成绩,将获得某一给定分数的学生人数输出。输入格式:输入在第 1 行给出不超过 10^ ​5​ 的正整数 N,即学生总人数。随后一行给出 N 名学生的百分制整数成绩,中间以空格分隔。最后一行给出要查询的分数个数 K(不超过 N 的正整数),随后是 K 个分数,中间以空格分隔。输出格式:在一行中按查询顺序给出得分等于指定分数的学生人数,中间以空格分隔,但行末不得有多余空格。输入样例:1060 75 90 55 75 99

2021-02-19 21:57:52 74

原创 PAT B1033 旧键盘打字 (20 分)

PAT B1033 旧键盘打字 (20 分)旧键盘上坏了几个键,于是在敲一段文字的时候,对应的字符就不会出现。现在给出应该输入的一段文字、以及坏掉的那些键,打出的结果文字会是怎样?输入格式:输入在 2 行中分别给出坏掉的那些键、以及应该输入的文字。其中对应英文字母的坏键以大写给出;每段文字是不超过 10^ ​5​​ 个字符的串。可用的字符包括字母 [a-z, A-Z]、数字 0-9、以及下划线 _(代表空格)、,、.、-、+(代表上档键)。题目保证第 2 行输入的文字串非空。注意:如果上档键坏掉了

2021-02-19 21:51:33 146

原创 PAT A1084 Broken Keyboard (20 分)/B1029 旧键盘 (20 分)

PAT A1084 Broken Keyboard (20 分)/B1029 旧键盘 (20 分)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 type,

2021-02-19 18:33:36 77

原创 PAT A1095 Cars on Campus (30 分)

PAT A1095 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 are supposed to tell, at

2021-02-19 17:27:32 107

原创 PAT A1080 Graduate Admission (30 分)

PAT A1080 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 procedure.Each app

2021-02-18 19:32:52 112

原创 PAT A1083 List Grades (25 分)

PAT A1083 List Grades (25 分)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 are in a given interval.In

2021-02-18 16:46:39 89

原创 PAT A1075 PAT Judge (25 分)

PAT A1075 PAT Judge (25 分)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 contains one test case. For each

2021-02-18 16:34:19 97

原创 PAT A1055 The World‘s Richest (25 分)

PAT A1055 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 people in a certain rang

2021-02-16 19:52:52 143

原创 PAT A1028 List Sorting (25 分)

PAT A1028 List Sorting (25 分)Excel can sort records according to any column. Now you are supposed to imitate this function.Input Specification:Each input file contains one test case. For each case, the first line contains two integers N (≤10^​5​​ ) and

2021-02-16 18:43:43 83

原创 PAT A1016 Phone Bills (25 分)

PAT A1016 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 a customer starts connectin

2021-02-16 18:23:05 93

原创 PAT A 1012 The Best Rank (25 分)

PAT A 1012 The Best Rank (25 分)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,

2021-02-14 21:02:06 78

原创 PAT A1062 Talent and Virtue (25 分)/B 1015 德才论 (25 分)

PAT A1062 Talent and Virtue (25 分)/B 1015 德才论 (25 分)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 theory, a man being outstanding in both talent and virtue

2021-02-14 18:50:38 128

原创 PAT A1101 Quick Sort (25 分)/B 1045 快速排序 (25 分)

PAT A1101 Quick Sort (25 分)/B 1045 快速排序 (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 th

2021-02-14 17:46:15 191

原创 PAT A1093 Count PAT‘s (25 分)/B 1040 有几个PAT (25 分)

PAT A1093 Count PAT’s (25 分)/B 1040 有几个PAT (25 分)The string APPAPT contains two PAT’s as substrings. The first one is formed by the 2nd, the 4th, and the 6th characters, and the second one is formed by the 3rd, the 4th, and the 6th characters.Now given a

2021-02-14 16:24:32 99

原创 PAT B1023 组个最小数 (20 分)

PAT B1023 组个最小数 (20 分)给定数字 0-9 各若干个。你可以以任意顺序排列这些数字,但必须全部使用。目标是使得最后得到的数尽可能小(注意 0 不能做首位)。例如:给定两个 0,两个 1,三个 5,一个 8,我们得到的最小的数就是 10015558。现给定数字,请编写程序输出能够组成的最小的数。输入格式:输入在一行中给出 10 个非负整数,顺序表示我们拥有数字 0、数字 1、……数字 9 的个数。整数间用一个空格分隔。10 个数字的总个数不超过 50,且至少拥有 1 个非 0 的数字

2021-02-13 18:56:44 122

原创 PAT B1020 月饼 (25 分)/A 1070 Mooncake (25 分)

PAT B1020 月饼 (25 分)月饼是中国人在中秋佳节时吃的一种传统食品,不同地区有许多不同风味的月饼。现给定所有种类月饼的库存量、总售价、以及市场的最大需求量,请你计算可以获得的最大收益是多少。注意:销售时允许取出一部分库存。样例给出的情形是这样的:假如我们有 3 种月饼,其库存量分别为 18、15、10 万吨,总售价分别为 75、72、45 亿元。如果市场的最大需求量只有 20 万吨,那么我们最大收益策略应该是卖出全部 15 万吨第 2 种月饼、以及 5 万吨第 3 种月饼,获得 72 + 4

2021-02-13 18:41:29 126

空空如也

空空如也

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

TA关注的人

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