![](https://img-blog.csdnimg.cn/20201014180756930.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
PAT (Advanced Level) Practice
文章平均质量分 81
我不是相龙
编程小白,从零开始,欢迎大佬指点。
展开
-
1049Counting Ones
The task is simple: given any positive integerN, you are supposed to count the total number of 1's in the decimal form of the integers from 1 toN. For example, givenNbeing 12, there are five 1's in 1, 10, 11, and 12.Input Specification:Each input f...原创 2022-03-10 11:16:27 · 795 阅读 · 0 评论 -
1008Elevator
The highest building in our city has only one elevator. A request list is made up withNpositive numbers. The numbers denote at which floors the elevator will stop, in specified order. It costs 6 seconds to move the elevator up one floor, and 4 seconds to..原创 2022-03-10 11:01:42 · 910 阅读 · 0 评论 -
1048Find Coins(two pointers)
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 requirement of the payment: for eac原创 2022-03-10 09:34:51 · 55 阅读 · 0 评论 -
1029Median
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 is defined to be the me原创 2022-03-10 09:26:03 · 917 阅读 · 0 评论 -
1089Insert or Merge
According to Wikipedia:Insertion sortiterates, consuming one input element each repetition, and growing a sorted output list. Each iteration, insertion sort removes one element from the input data, finds the location it belongs within the sorted list, a.原创 2022-03-08 22:34:07 · 54 阅读 · 0 评论 -
1048 Find Coins(二分法处理)
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 requirement of the payment: for eac原创 2022-03-08 11:17:41 · 67 阅读 · 0 评论 -
1044Shopping in Mars
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原创 2022-03-08 11:03:48 · 133 阅读 · 0 评论 -
1010 Radix
Given a pair of positive integers, for example, 6 and 110, can this equation 6 = 110 be true? The answer isyes, if 6 is a decimal number and 110 is a binary number.Now for any pair of positive integersN1andN2, your task is to find the radix of one ...原创 2022-03-08 10:27:52 · 45 阅读 · 0 评论 -
1060Are They Equal
If a machine can save only 3 significant digits, the float numbers 12300 and 12358.9 are considered equal since they are both saved as0.123×105with simple chopping. Now given the number of significant digits on a machine and two float numbers, you are su..原创 2022-03-07 10:22:53 · 125 阅读 · 0 评论 -
1067 Sort with Swap(0,i)
Given any permutation of the numbers {0, 1, 2,...,N−1}, it is easy to sort them in increasing order. But what ifSwap(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 followin...原创 2022-03-03 11:09:47 · 413 阅读 · 0 评论 -
1037 Magic Coupon
The magic shop in Mars is offering some magic coupons. Each coupon has an integerNprinted on it, meaning that when you use this coupon with a product, you may getNtimes the value of that product back! What is more, the shop also offers some bonus produ...原创 2022-03-03 10:44:44 · 395 阅读 · 0 评论 -
1033 To Fill or Not to Fill
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 to car原创 2022-03-03 10:21:44 · 54 阅读 · 0 评论 -
1048 Find Coins
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 requirement of the payment: for eac原创 2022-03-02 23:02:33 · 48 阅读 · 0 评论 -
1041Be Unique
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,104]. The first one who bets on a unique number wins. For example, if there are 7 people原创 2022-03-02 10:50:45 · 130 阅读 · 0 评论 -
1050 String Subtration
Given two stringsS1andS2,S=S1−S2is defined to be the remaining string after taking all the characters inS2fromS1. Your task is simply to calculateS1−S2for any given strings. However, it might not be that simple to do itfast.Input Speci...原创 2022-03-02 11:01:50 · 41 阅读 · 0 评论 -
1095 Cars on Campus
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 num原创 2022-03-01 11:08:37 · 48 阅读 · 0 评论 -
1080Graduate Admission
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 applicant will have to provide two gra原创 2022-03-01 10:14:36 · 53 阅读 · 0 评论 -
1083 List Grades
Given a list ofNstudent 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.Input Specification:Each inp..原创 2022-02-27 10:39:36 · 170 阅读 · 0 评论 -
1075 PAT Judge
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 case, the first line cont原创 2022-02-25 12:00:31 · 45 阅读 · 0 评论 -
1055 The World‘s Richest
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 range of ages. That is, given the net wor原创 2022-02-25 10:53:43 · 46 阅读 · 0 评论 -
1028 List Sorting
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 integersN(≤105) andC, whereNis the number of recor...原创 2022-02-25 10:19:22 · 54 阅读 · 0 评论 -
1025 PAT Ranking
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 will be merged immediately after the test. Now it is your原创 2022-02-22 23:25:14 · 44 阅读 · 0 评论 -
1016 Phone Bills
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, the原创 2022-02-20 23:08:13 · 52 阅读 · 0 评论 -
1012 The Best Rank
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), andE- English. At the mean time, we encourage students by emphasi...原创 2022-02-19 21:54:52 · 39 阅读 · 0 评论 -
1082 Read Number in Chinese
Given an integer with no more than 9 digits, you are supposed to read it in the traditional Chinese way. OutputFufirst if it is negative. For example, -123456789 is read asFu yi Yi er Qian san Bai si Shi wu Wan liu Qian qi Bai ba Shi jiu. Note: zero (...原创 2022-02-19 20:47:04 · 55 阅读 · 0 评论 -
1077 Kuchiguse
The Japanese language is notorious for its sentence ending particles. Personal preference of such particles can be considered as a reflection of the speaker's personality. Such a preference is called "Kuchiguse" and is often exaggerated artistically in Ani原创 2022-01-10 19:09:44 · 48 阅读 · 0 评论 -
1035 Password
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 distinguish1(one) froml(Lin lowercase), or0(zero) fromO(oin uppercase). One ...原创 2022-01-08 22:20:39 · 46 阅读 · 0 评论 -
1005 Spell It Right
Given a non-negative integerN, your task is to compute the sum of all the digits ofN, and output every digit of the sum in English.Input Specification:Each input file contains one test case. Each case occupies one line which contains anN(≤10100)....原创 2022-01-08 21:30:14 · 41 阅读 · 0 评论 -
1001 A+B Format
Calculatea+band output the sum in standard format -- that is, the digits must be separated into groups of three by commas (unless there are less than four digits).Input Specification:Each input file contains one test case. Each case contains a pair o..原创 2022-01-08 19:08:36 · 316 阅读 · 0 评论 -
1006 换个方式输出整数
让我们用字母B来表示“百”、字母S表示“十”,用12...n来表示不为零的个位数字n(<10),换个格式来输出任一个不超过 3 位的正整数。例如234应该被输出为BBSSS1234,因为它有 2 个“百”、3 个“十”、以及个位的 4。输入格式:每个测试输入包含 1 个测试用例,给出正整数n(<1000)。输出格式:每个测试用例的输出占一行,用规定的格式输出n。输入样例 1:234输出样例 1:BBSSS1234输入样例 2:...原创 2022-01-04 20:26:17 · 60 阅读 · 0 评论 -
1058 A+B in Hogwarts
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 Sickle, it's easy enough." Your job is to write a program原创 2022-01-04 20:12:54 · 236 阅读 · 0 评论 -
1027 Colors in Mars
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 forRed, the middle 2 digits forGreen, and the last 2 digits forBlue. The only ...原创 2022-01-04 19:17:07 · 208 阅读 · 0 评论 -
1019 General Palindromic Number
A number that will be the same when it is written forwards or backwards is known as aPalindromic Number. For example, 1234321 is a palindromic number. All single digit numbers are palindromic numbers.Although palindromic numbers are most often considere.原创 2022-01-04 19:05:18 · 779 阅读 · 0 评论 -
1031 Hello World for u
编译软件:visual studio编译语言:c语言参考代码:#include<cstdio>#include<cstring>int main(){ char str[100], ans[40][40]; gets_s(str, 100); int N = strlen(str); int n1 = (N + 2) / 3, n3 = n1, n2 = N + 2 - n1 - n3; for (int i = 1; i ...原创 2022-01-03 20:51:52 · 137 阅读 · 0 评论 -
1036 Boys vs Girls
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.Input Specification:Each input file contains one test case. Each case contains a positive integerN, follo.原创 2022-01-03 19:38:35 · 127 阅读 · 0 评论 -
1006 Sign In and Sign Out
For each test case, output in one line the ID numbers of the persons who have unlocked and locked the door on that day. The two ID numbers must be separated by one space.Note: It is guaranteed that the records are consistent. That is, the sign in time mu原创 2022-01-03 19:22:14 · 50 阅读 · 0 评论 -
1011 World Cup Betting
With the 2010 FIFA World Cup running, football fans the world over were becoming increasingly excited as the best players from the best teams doing battles for the World Cup trophy in South Africa. Similarly, football betting fans were putting their money原创 2022-01-03 18:04:21 · 60 阅读 · 0 评论 -
1009 Product of Polynomials
Product of PolynomialsThis time, you are supposed to findA×BwhereAandBare two polynomials.Input Specification:Each input file contains one test case. Each case occupies 2 lines, and each line contains the information of a polynomial:KN1aN1...原创 2021-10-23 23:45:01 · 87 阅读 · 0 评论 -
1002 A+B for Polynomials
A+B for PolynomialsThis time, you are supposed to findA+BwhereAandBare two polynomials.Input Specification:Each input file contains one test case. Each case occupies 2 lines, and each line contains the information of a polynomial:KN1aN1...原创 2021-10-23 23:18:27 · 43 阅读 · 0 评论 -
1065 A+B and C (64bit)
A+B and CGiven three integersA,BandCin (−263,263), you are supposed to tell whetherA+B>C.Input Specification:The first line of the input gives the positive number of test cases,T(≤10). ThenTtest cases follow, each consists of a single l...原创 2021-10-19 15:07:40 · 48 阅读 · 0 评论