自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

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

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

原创 1003我要通过

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

2022-03-10 10:47:08 67

原创 1019数字黑洞

给定任一个各位数字不完全相同的 4 位正整数,如果我们先把 4 个数字按非递增排序,再按非递减排序,然后用第 1 个数字减第 2 个数字,将得到一个新的数字。一直重复这样做,我们很快会停在有“数字黑洞”之称的6174,这个神奇的数字也叫 Kaprekar 常数。例如,我们从6767开始,将得到7766 - 6677 = 10899810 - 0189 = 96219621 - 1269 = 83528532 - 2358 = 61747641 - 1467 = 6174... ....

2022-03-10 10:29:30 101

原创 1045快速排序

著名的快速排序算法里有一个经典的划分过程:我们通常采用某种方法取一个元素作为主元,通过交换,把比主元小的元素放到它的左边,比主元大的元素放到它的右边。 给定划分后的N个互不相同的正整数的排列,请问有多少个元素可能是划分前选取的主元?例如给定N=5, 排列是1、3、2、4、5。则:1 的左边没有元素,右边的元素都比它大,所以它可能是主元; 尽管 3 的左边元素都比它小,但其右边的 2 比它小,所以它不能是主元; 尽管 2 的右边元素都比它大,但其左边的 3 比它大,所以它不能是主元; 类似...

2022-03-10 10:18:57 94

原创 1040有几个PAT

字符串APPAPT中包含了两个单词PAT,其中第一个PAT是第 2 位(P),第 4 位(A),第 6 位(T);第二个PAT是第 3 位(P),第 4 位(A),第 6 位(T)。现给定字符串,问一共可以形成多少个PAT?输入格式:输入只有一行,包含一个字符串,长度不超过105,只包含P、A、T三种字母。输出格式:在一行中输出给定字符串中包含多少个PAT。由于结果可能比较大,只输出对 1000000007 取余数的结果。输入样例:APPAPT输出样...

2022-03-10 09:55:20 154

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

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

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

原创 1030完美数列(two pointers)

给定一个正整数数列,和正整数p,设这个数列中的最大值是M,最小值是m,如果M≤mp,则称这个数列是完美数列。现在给定参数p和一些正整数,请你从中选择尽可能多的数构成一个完美数列。输入格式:输入第一行给出两个正整数N和p,其中N(≤105)是输入的正整数的个数,p(≤109)是给定的参数。第二行给出N个正整数,每个数不超过109。输出格式:在一行中输出最多可以选择多少个数可以用它们组成一个完美数列。输入样例:10 82 3 20 4 5 1 6 7 8...

2022-03-08 21:59:57 51

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

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

原创 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 integersN1​andN2​, your task is to find the radix of one ...

2022-03-08 10:27:52 43

原创 1030完美数列

给定一个正整数数列,和正整数p,设这个数列中的最大值是M,最小值是m,如果M≤mp,则称这个数列是完美数列。现在给定参数p和一些正整数,请你从中选择尽可能多的数构成一个完美数列。输入格式:输入第一行给出两个正整数N和p,其中N(≤105)是输入的正整数的个数,p(≤109)是给定的参数。第二行给出N个正整数,每个数不超过109。输出格式:在一行中输出最多可以选择多少个数可以用它们组成一个完美数列。输入样例:10 82 3 20 4 5 1 6 7 8...

2022-03-07 11:09:34 50

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

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

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

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

原创 1023 组个最小数

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

2022-03-03 09:45:09 205

原创 1020 月饼

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

2022-03-03 09:35:44 50

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

原创 1005继续(3n+1)猜想

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

2022-03-02 11:14:05 42

原创 1050 String Subtration

Given two stringsS1​andS2​,S=S1​−S2​is defined to be the remaining string after taking all the characters inS2​fromS1​. Your task is simply to calculateS1​−S2​for any given strings. However, it might not be that simple to do itfast.Input Speci...

2022-03-02 11:01:50 41

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

原创 1047编程团体赛

编译软件:visual studio编译语言:c语言参考代码:#include<cstdio>const int maxn = 1010;int hashTable[maxn] = { 0 };int main(){ int n; scanf("%d", &n); for (int i = 0; i < n; i++) { int team, member, score; scanf("%d-%d...

2022-03-02 10:26:56 140

原创 1043输出PATest

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

2022-03-02 10:19:47 35

原创 1042字符统计

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

2022-03-02 10:07:30 40

原创 1039到底买不买

小红想买些珠子做一串自己喜欢的珠串。卖珠子的摊主有很多串五颜六色的珠串,但是不肯把任何一串拆散了卖。于是小红要你帮忙判断一下,某串珠子里是否包含了全部自己想要的珠子?如果是,那么告诉她有多少多余的珠子;如果不是,那么告诉她缺了多少珠子。为方便起见,我们用[0-9]、[a-z]、[A-Z]范围内的字符来表示颜色。例如在图1中,第3串是小红想做的珠串;那么第1串可以买,因为包含了全部她想要的珠子,还多了8颗不需要的珠子;第2串不能买,因为没有黑色珠子,并且少了一颗红色的珠子。图 1输入格式:

2022-03-02 09:57:40 146

原创 1038统计

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

2022-03-01 22:48:58 121

原创 1033旧键盘打字

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

2022-03-01 22:38:18 39

原创 1029旧键盘

旧键盘上坏了几个键,于是在敲一段文字的时候,对应的字符就不会出现。现在给出应该输入的一段文字、以及实际被输入的文字,请你列出肯定坏掉的那些键。输入格式:输入在 2 行中分别给出应该输入的文字、以及实际被输入的文字。每段文字是不超过 80 个字符的串,由字母 A-Z(包括大、小写)、数字 0-9、以及下划线_(代表空格)组成。题目保证 2 个字符串均非空。输出格式:按照发现顺序,在一行中输出坏掉的键。其中英文字母只输出大写,每个坏键只输出一次。题目保证至少有 1 个坏键。输入样例:.

2022-03-01 22:23:12 39

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

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

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

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

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

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

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

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

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

空空如也

空空如也

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

TA关注的人

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