PAT甲级 1108 Finding Average (20分)

The basic task is simple: given N real numbers, you are supposed to calculate their average. But what makes it complicated is that some of the input numbers might not be legal. A legal input is a real number in [−1000,1000] and is accurate up to no more than 2 decimal places. When you calculate the average, those illegal numbers must not be counted in. Input Specification: Each input file contains one test case. For each case, the first line gives a positive integer N (≤100). Then N numbers are given in the next line, separated by one space. ...

April 15, 2020 · 3 min

PAT甲级 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 the city and several candidate locations for the gas station, you are supposed to give the best recommendation. If there are more than one solution, output the one with the smallest average distance to all the houses. If such a solution is still not unique, output the one with the smallest index number. ...

April 13, 2020 · 4 min

PAT甲级 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 monitoring the real-time capacity of all the stations. A station is said to be in perfect condition if it is exactly half-full. If a station is full or empty, PBMC will collect or send bikes to adjust the condition of that station to perfect. And more, all the stations on the way will be adjusted as well. ...

April 12, 2020 · 5 min

PAT考场 Dev C++ 5.10 配置

根据往年 (2019) 年浙大软件学院的考研复试公告,如果今年 (2020) 是线下复试,且考场没有变化的话,机试应该还是在 浙大紫金港校区(如下图)。 浙大软院招生通知:http://www.cst.zju.edu.cn/2019/0307/c36207a1478348/page.htm 从 PAT 官网可以找到紫金港的机房配置: PAT 考点联盟:https://www.patest.cn/location 我本人选择使用 Dev C++ 5.10 版本,考试那天在考场需要先对其作以下配置(当然也许已经配置好了): 打开产生调试信息 在 “工具(Tools)” -> “编译选项(Compiler Options)" 中: 点击 “代码生成/优化(Settings)” 选项卡中的 "连接器(Linker)" 选项卡,将 "产生调试信息(Generate debugging information)" 选项改为 “Yes”。 这样,就可以愉快的 Debug 了~ 添加 C++ 11 支持 由于 PAT 的 OJ 是支持 C++ 11 的,故最好打开 C++ 11 支持。 方法一(推荐) 在 “工具(Tools)” -> “编译选项(Compiler Options)" 中,“代码生成/优化(Settings)” 选项卡下的 “代码生成(Code Generation)” 选项卡中,将 “语言标准(Language Standard)(-std)” 设置为 ISO C++11 即可。 ...

April 11, 2020 · 1 min

PAT甲级 1021 Deepest Root (25分)

A graph which is connected and acyclic can be considered a tree. The height of the tree depends on the selected root. Now you are supposed to find the root that results in a highest tree. Such a root is called the deepest root. Input Specification: Each input file contains one test case. For each case, the first line contains a positive integer N (≤10^4) which is the number of nodes, and hence the nodes are numbered from 1 to N. Then N−1 lines follow, each describes an edge by given the two adjacent nodes’ numbers. ...

April 10, 2020 · 2 min

PAT甲级 1013 Battle Over Cities (25分)

It is vitally important to have all the cities connected by highways in a war. If a city is occupied by the enemy, all the highways from/toward that city are closed. We must know immediately if we need to repair any other highways to keep the rest of the cities connected. Given the map of cities which have all the remaining highways marked, you are supposed to tell the number of highways need to be repaired, quickly. ...

April 9, 2020 · 2 min

PAT甲级 1032 Sharing (25分)

To store English words, one method is to use linked lists and store a word letter by letter. To save some space, we may let the words share the same sublist if they share the same suffix. For example, loading and being are stored as showed in Figure 1. You are supposed to find the starting position of the common suffix (e.g. the position of i in Figure 1). ...

April 7, 2020 · 2 min

PAT甲级 1056 Mice and Rice (25分)

Mice and Rice is the name of a programming contest in which each programmer must write a piece of code to control the movements of a mouse in a given map. The goal of each mouse is to eat as much rice as possible in order to become a FatMouse. First the playing order is randomly decided for N P programmers. Then every N G programmers are grouped in a match. The fattest mouse in a group wins and enters the next turn. All the losers in this turn are ranked the same. Every N G winners are then grouped in the next match until a final winner is determined. ...

April 6, 2020 · 3 min

PAT甲级 1100 Mars Numbers (20分)

People on Mars count their numbers with base 13: Zero on Earth is called “tret” on Mars. The numbers 1 to 12 on Earth is called “jan, feb, mar, apr, may, jun, jly, aug, sep, oct, nov, dec” on Mars, respectively. For the next higher digit, Mars people name the 12 numbers as “tam, hel, maa, huh, tou, kes, hei, elo, syy, lok, mer, jou”, respectively. For examples, the number 29 on Earth is called “hel mar” on Mars; and “elo nov” on Mars corresponds to 115 on Earth. In order to help communication between people from these two planets, you are supposed to write a program for mutual translation between Earth and Mars number systems. ...

April 6, 2020 · 2 min

PAT甲级 1060 Are They Equal (25分)

If a machine can save only 3 significant digits, the float numbers 12300 and 12358.9 are considered equal since they are both saved as 0.123×105 with simple chopping. Now given the number of significant digits on a machine and two float numbers, you are supposed to tell if they are treated equal in that machine. Input Specification: Each input file contains one test case which gives three numbers N, A and B, where N (<100) is the number of significant digits, and A and B are the two float numbers to be compared. Each float number is non-negative, no greater than 10100, and that its total digit number is less than 100. ...

April 4, 2020 · 2 min