![](https://img-blog.csdnimg.cn/20201014180756780.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
PAT
「已注销」
这个作者很懒,什么都没留下…
展开
-
进阶实验6-3.1 红色警报 (25分)
进阶实验6-3.1 红色警报 (25分)战争中保持各个城市间的连通性非常重要。本题要求你编写一个报警程序,当失去一个城市导致国家被分裂为多个无法连通的区域时,就发出红色警报。注意:若该国本来就不完全连通,是分裂的k个区域,而失去一个城市并不改变其他城市之间的连通性,则不要发出警报。输入格式:输入在第一行给出两个整数N(0<N≤500)和M(≤5000),分别为城市个数(于是默认城市从0到N-1编号)和连接两城市的通路条数。随后M行,每行给出一条通路所连接的两个城市的编号,其间以...原创 2020-08-20 00:56:19 · 249 阅读 · 0 评论 -
基础实验6-2.3 拯救007 (25分) [浙大版《数据结构学习与实验指导(第2版)》]
题目连接:基础实验6-2.3 拯救007 (25分)在老电影“007之生死关头”(Live and Let Die)中有一个情节,007被毒贩抓到一个鳄鱼池中心的小岛上,他用了一种极为大胆的方法逃脱 —— 直接踩着池子里一系列鳄鱼的大脑袋跳上岸去!(据说当年替身演员被最后一条鳄鱼咬住了脚,幸好穿的是特别加厚的靴子才逃过一劫。)设鳄鱼池是长宽为100米的方形,中心坐标为 (0, 0),且东北角坐标为 (50, 50)。池心岛是以 (0, 0) 为圆心、直径15米的圆。给定池中分布的鳄鱼的坐标、以及00原创 2020-08-17 00:46:52 · 630 阅读 · 0 评论 -
案例6-1.3 哥尼斯堡的“七桥问题” (25分) 浙大版《数据结构学习与实验指导(第2版)》
案例6-1.3 哥尼斯堡的“七桥问题” (25分)哥尼斯堡是位于普累格河上的一座城市,它包含两个岛屿及连接它们的七座桥,如下图所示。可否走过这样的七座桥,而且每桥只走过一次?瑞士数学家欧拉(Leonhard Euler,1707—1783)最终解决了这个问题,并由此创立了拓扑学。这个问题如今可以描述为判断欧拉回路是否存在的问题。欧拉回路是指不令笔离开纸面,可画过图中每条边仅一次,且可以回到起点的一条回路。现给定一个无向图,问是否存在欧拉回路?输入格式:输入第一行给出两个正整数,分别.原创 2020-08-14 00:48:32 · 311 阅读 · 0 评论 -
基础实验6-2.2 汉密尔顿回路 (25分) --浙大版《数据结构学习与实验指导(第2版)》
题目连接:基础实验6-2.2 汉密尔顿回路 (25分) 著名的“汉密尔顿(Hamilton)回路问题”是要找一个能遍历图中所有顶点的简单回路(即每个顶点只访问 1 次)。本题就要求你判断任一给定的回路是否汉密尔顿回路。输入格式:首先第一行给出两个正整数:无向图中顶点数N(2<N≤200)和边数M。随后M行,每行给出一条边的两个端点,格式为“顶点1 顶点2”,其中顶点从 1 到N编号。再下一行给出一个正整数K,是待检验的回路的条数。随后K行,每行给出一条待检回路,格式为:...原创 2020-08-13 00:05:07 · 375 阅读 · 1 评论 -
基础实验8-1.2 直捣黄龙 (30分) [浙大版《数据结构学习与实验指导(第2版)》题目集]
基础实验8-1.2 直捣黄龙 (30分)本题是一部战争大片 —— 你需要从己方大本营出发,一路攻城略地杀到敌方大本营。首先时间就是生命,所以你必须选择合适的路径,以最快的速度占领敌方大本营。当这样的路径不唯一时,要求选择可以沿途解放最多城镇的路径。若这样的路径也不唯一,则选择可以有效杀伤最多敌军的路径。输入格式:输入第一行给出2个正整数N(2≤N≤200,城镇总数)和K(城镇间道路条数),以及己方大本营和敌方大本营的代号。随后N-1行,每行给出除了己方大本营外的一个城镇的代号和驻守的敌军...原创 2020-08-12 00:55:12 · 1235 阅读 · 0 评论 -
PAT(甲级)2019年春季考试
7-1Sexy Primes(20分)Sexy primes are pairs of primes of the form (p,p+6), so-named since "sex" is the Latin word for "six". (Quoted fromhttp://mathworld.wolfram.com/SexyPrimes.html)Now given an integer, you are supposed to tell if it is a sexy prime....原创 2020-07-23 18:15:52 · 691 阅读 · 0 评论 -
7-2 Block Reversing (25分) 【PAT 甲级19年冬考】
Given a singly linked listL. Let us consider everyKnodes as ablock(if there are less thanKnodes at the end of the list, the rest of the nodes are still considered as a block). Your job is to reverse all the blocks inL. For example, givenLas 1→2→3...原创 2020-07-22 10:53:48 · 454 阅读 · 6 评论 -
7-4 Cartesian Tree (30分) 【PAT 甲级19年冬考】
ACartesian treeis a binary tree constructed from a sequence of distinct numbers. The tree is heap-ordered, and an inorder traversal returns the original sequence. For example, given the sequence { 8, 15, 3, 4, 1, 5, 12, 10, 18, 6 }, the min-heap Cartesia..原创 2020-07-22 10:36:48 · 147 阅读 · 0 评论 -
7-3 Summit (25分) [PAT甲级 19年冬考]
Asummit(峰会) is a meeting of heads of state or government. Arranging the rest areas for the summit is not a simple job. The ideal arrangement of one area is to invite those heads so that everyone is a direct friend of everyone.Now given a set of tentati..原创 2020-07-22 10:34:23 · 131 阅读 · 0 评论 -
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 integerEsuch that it is forEdays that one rides more thanEmiles. Eddington's ownE...原创 2020-07-11 00:00:47 · 111 阅读 · 0 评论 -
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-07-09 23:50:02 · 119 阅读 · 0 评论 -
1148 Werewolf - Simple Version (20分)
Werewolf(狼人杀) is a game in which the players are partitioned into two parties: the werewolves and the human beings. Suppose that in a game,player #1 said: "Player #2 is a werewolf."; player #2 said: "Player #3 is a human."; player #3 said: "Player #4 i原创 2020-07-09 01:07:00 · 139 阅读 · 0 评论 -
1132 Cut Integer (20分)
Cutting an integer means to cut a K digits lone integer Z into two integers of (K/2) digits long integers A and B. For example, after cutting Z = 167334, we have A = 167 and B = 334. It is interesting to see that Z can be devided by the product of A and...原创 2020-07-05 01:02:46 · 88 阅读 · 0 评论 -
1129 Recommendation System (25分)
Recommendation system predicts the preference that a user would give to an item. Now you are asked to program a very simple recommendation system that rates the user's preference by the number of times that an item has been accessed by this user.Input Sp原创 2020-07-05 00:38:50 · 136 阅读 · 0 评论 -
1121 Damn Single (25分)
"Damn Single (单身狗)" is the Chinese nickname for someone who is being single. You are supposed to find those who are alone in a big party, so they can be taken care of.Input Specification:Each input file contains one test case. For each case, the first原创 2020-07-03 00:46:04 · 85 阅读 · 0 评论 -
1109 Group Photo (25分)
Formation is very important when taking a group photo. Given the rules of formingKrows withNpeople as the following: The number of people in each row must beN/K(round down to the nearest integer), with all the extra people (if any) standing in the...原创 2020-07-02 00:52:21 · 144 阅读 · 0 评论 -
1105 Spiral Matrix (25分)
This time your job is to fill a sequence ofNpositive integers into aspiral matrixin non-increasing order. A spiral matrix is filled in from the first element at the upper-left corner, then move in a clockwise spiral. The matrix hasmrows andncolumns...原创 2020-07-01 01:27:49 · 106 阅读 · 0 评论 -
1014 Waiting in Line (30分)
Suppose a bank hasNwindows open for service. There is a yellow line in front of the windows which devides the waiting area into two parts. The rules for the customers to wait in line are:The space inside the yellow line in front of each window is enoug..原创 2020-06-28 01:10:20 · 161 阅读 · 1 评论 -
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 prime found in consecutive digits of the natural constant原创 2020-06-27 01:02:31 · 78 阅读 · 0 评论 -
1116 Come on Lets 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 the following:0、 The Champion will receive a "Mystery原创 2020-06-26 01:27:46 · 193 阅读 · 0 评论 -
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 forktimes.Now given a resulting string on screen, you are supposed to list all th...原创 2020-06-25 01:36:03 · 139 阅读 · 0 评论 -
1072 Gas Station (30分)
A gas station has to be built at such a location that the minimum distance between the station and any of the residential housing is as far away as possible. However it must guarantee that all the houses are in its service range.Now given the map of t...原创 2020-06-24 00:24:56 · 145 阅读 · 0 评论 -
1018 Public Bike Management (30分)
There is a public bike service in Hangzhou City which provides great convenience to the tourists from all over the world. One may rent a bike at any station and return it to any other stations in the city.The Public Bike Management Center (PBMC) keeps mo原创 2020-06-21 01:34:43 · 85 阅读 · 0 评论 -
1136 A Delayed Palindrome (20分)
Consider a positive integerNwritten in standard notation withk+1digitsaiasak⋯a1a0with0≤ai<10for alliandak>0. ThenNispalindromicif and only ifai=ak−ifor alli. Zero is written 0 and is also palindromic by def...原创 2020-06-18 01:14:20 · 99 阅读 · 0 评论 -
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,Tfor the top level,Afor advance andBfor basic; the 2nd - 4th digits are the test site number, ranged from 101 to 999; the 5th - 10th digits giv...原创 2020-06-17 01:50:42 · 133 阅读 · 0 评论 -
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 contains one test case. For each case, the first line gives a原创 2020-06-15 00:30:58 · 107 阅读 · 0 评论 -
1124 Raffle for Weibo Followers (20分)
John got a full mark on PAT. He was so happy that he decided to hold a raffle(抽奖) for his followers on Weibo -- that is, he would select winners from every N followers who forwarded his post, and give away gifts. Now you are supposed to help him generate t原创 2020-06-14 00:55:29 · 125 阅读 · 0 评论 -
1108 Finding Average (20分)
The basic task is simple: givenNreal numbers, you are supposed to calculate their average. But what makes it complicated is that some of the input numbers might not be legal. Alegalinput is a real number in [−1000,1000] and is accurate up to no more th...原创 2020-06-13 01:00:39 · 107 阅读 · 0 评论 -
1130 Infix Expression (25分)
Given a syntax tree (binary), you are supposed to output the corresponding infix expression, with parentheses reflecting the precedences of the operators.Input Specification:Each input file contains one test case. For each case, the first line gives a原创 2020-06-04 01:19:20 · 75 阅读 · 0 评论 -
1155 Heap Paths (30分)
In computer science, aheapis 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 (in a max heap) or less than or equal to (in a min heap) t..原创 2020-06-03 00:26:55 · 84 阅读 · 0 评论 -
1114 Family Property (25分)
This time, you are supposed to help us collect the data for family-owned property. Given each person's family members, and the estate(房产)info under his/her own name, we need to know the size of each family, and the average area and number of sets of their原创 2020-05-29 22:31:58 · 108 阅读 · 0 评论 -
1137 Final Grading (25分)
For a student taking the online course "Data Structures" on China University MOOC (http://www.icourse163.org/), to be qualified for a certificate, he/she must first obtain no less than 200 points from the online programming assignments, and then receive a原创 2020-05-25 02:26:48 · 85 阅读 · 0 评论 -
1149 Dangerous Goods Packaging (25分)
When shipping goods with containers, we have to be careful not to pack some incompatible goods into the same container, or we might get ourselves in serious trouble. For example, oxidizing agent (氧化剂) must not be packed with flammable liquid (易燃液体), or it原创 2020-05-24 01:35:13 · 111 阅读 · 0 评论 -
1120 Friend Numbers (20分)
Two integers are called "friend numbers" if they share the same sum of their digits, and the sum is their "friend ID". For example, 123 and 51 are friend numbers since 1+2+3 = 5+1 = 6, and 6 is their friend ID. Given some numbers, you are supposed to co...原创 2020-05-24 00:29:02 · 83 阅读 · 0 评论 -
1045 Favorite Color Stripe (30分)
Eva is trying to make her own color stripe out of a given one. She would like to keep only her favorite colors in her favorite order by cutting off those unwanted pieces and sewing the remaining parts together to form her favorite color stripe.It is said原创 2020-05-22 00:15:36 · 115 阅读 · 0 评论 -
1007 Maximum Subsequence Sum (25分) [DP]
Given a sequence ofKintegers {N1,N2, ...,NK}. A continuous subsequence is defined to be {Ni,Ni+1, ...,Nj} where1≤i≤j≤K. The Maximum Subsequence is the continuous subsequence which has the largest sum of its elements. For exa...原创 2020-05-21 00:54:24 · 137 阅读 · 0 评论 -
1139 First Contact (30分)
Unlike in nowadays, the way that boys and girls expressing their feelings of love was quite subtle in the early years. When a boy A had a crush on a girl B, he would usually not contact her directly in the first place. Instead, he might ask another boy ...原创 2020-05-16 00:18:09 · 240 阅读 · 0 评论 -
1131 Subway Map (30分)
In the big cities, the subway systems always look so complex to the visitors. To give you some sense, the following figure shows the map of Beijing subway. Now you are supposed to help people with your computer skills! Given the starting position of you...原创 2020-05-15 00:43:45 · 169 阅读 · 0 评论 -
1019 General Palindromic Number (20分)
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.原创 2020-05-11 23:41:05 · 94 阅读 · 0 评论 -
1142 Maximal Clique (25分)
Acliqueis a subset of vertices of an undirected graph such that every two distinct vertices in the clique are adjacent. Amaximal cliqueis a clique that cannot be extended by including one more adjacent vertex. (Quoted fromhttps://en.wikipedia.org/wiki...原创 2020-05-11 00:45:58 · 135 阅读 · 0 评论