
C++
文章平均质量分 75
Tate_Brown
这个作者很懒,什么都没留下…
展开
-
SPFA+队列优化与迪杰斯特拉+优先队列(最小堆优化)解一道水题
其实算法还是挺有意思的,可惜我年纪大了,搞不动了,这种东西应该适合在中学时候搞。。题目:A traveler's map gives the distances between cities along the highways, together with the cost of each highway. Now you are supposed to write a program ...原创 2019-07-07 01:02:25 · 557 阅读 · 1 评论 -
PAT1034 Head of a Gang
上次三月没满分。。开始准备搞九月了,希望这次能满分吧。3月份的时候英文太差了,看的好累,现在感觉还好了些,看运气了。(其实目前唯一自信的科目只有数学,别的。。都是随缘佛系)。今天做了这道题。。我就服了,我三月去的时候没做这道,结果三月是题设背景和这题基本一样的题目就是加深复杂了一点。。我当时都看不懂Gang是什么意思。。血崩。应该是要并查集做,我这边锻炼下模拟能力用STL模拟做了一下也过了...原创 2019-07-04 00:21:27 · 275 阅读 · 0 评论 -
PAT甲级1004,1020解题报告
1004 Counting Leaves (30 point(s))A family hierarchy is usually presented by a pedigree tree. Your job is to count those family members who have no child.Input Specification:Each input file c...原创 2019-02-08 16:15:24 · 645 阅读 · 0 评论 -
PAT甲级1147解题报告
1147 Heaps (30 point(s))In computer science, a heap is 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 g...原创 2018-11-26 17:30:30 · 320 阅读 · 0 评论 -
PAT甲级1129解题报告
1129 Recommendation System (25 point(s))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 t...原创 2018-11-25 14:04:21 · 547 阅读 · 0 评论 -
PAT甲级1128解题报告
1128 N Queens Puzzle (20 point(s))The "eight queens puzzle" is the problem of placing eight chess queens on an 8×8 chessboard so that no two queens threaten each other. Thus, a solution requires tha...原创 2018-11-25 01:16:35 · 315 阅读 · 0 评论 -
PAT甲级1133解题报告
1133 Splitting A Linked List (25 point(s))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 v...原创 2018-11-23 15:14:00 · 521 阅读 · 0 评论 -
PAT甲级1097解题报告
1097 Deduplication on a Linked List (25 point(s))Given a singly linked list L with integer keys, you are supposed to remove the nodes with duplicated absolute values of the keys. That is, for each v...原创 2018-11-22 18:21:30 · 345 阅读 · 0 评论 -
PAT甲级1141解题报告
1141 PAT Ranking of Institutions (25 point(s))After each PAT, the PAT Center will announce the ranking of institutions based on their students' performances. Now you are asked to generate the ran...原创 2018-11-21 21:02:08 · 337 阅读 · 0 评论 -
PAT甲级1125解题报告
好几天没做了已经。。感觉有点变难了,这几天也比较忙就一天一题吧,挑了半天挑了道会做了。1125 Chain the Ropes (25 point(s))Given some segments of rope, you are supposed to chain them into one rope. Each time you may only fold two segments int...原创 2018-11-19 19:13:29 · 330 阅读 · 0 评论 -
PAT甲级1140,1144解题报告
1140 Look-and-say Sequence (20 point(s))Look-and-say sequence is a sequence of integers as the following:D, D1, D111, D113, D11231, D112213111, ...where D is in [0, 9] except 1. The (n+1)st nu...原创 2018-11-09 23:46:55 · 250 阅读 · 0 评论 -
PAT甲级1132和1136解题报告
1132 Cut Integer (20 point(s))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 = 16...原创 2018-11-09 00:34:31 · 248 阅读 · 0 评论 -
PAT甲级1121,1124解题报告
1121 Damn Single (25 point(s))"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....原创 2018-11-08 00:31:50 · 361 阅读 · 0 评论 -
PAT甲级1117,1120解题报告
1117 Eddington Number (25 point(s))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 max...原创 2018-11-06 23:35:33 · 278 阅读 · 0 评论 -
PAT甲级1108,1112解题报告
1108 Finding Average (20 point(s))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 n...原创 2018-11-05 15:12:06 · 261 阅读 · 0 评论 -
PAT甲级1104,1105解题报告
1104 Sum of Number Segments (20 point(s))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 1...原创 2018-11-04 10:45:10 · 393 阅读 · 0 评论 -
PAT甲级1100,1101解题报告
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 Earch is called "jan, feb, mar, apr, may, jun, jly, aug, sep...原创 2018-11-03 13:13:25 · 327 阅读 · 0 评论 -
PAT甲级1093,1098解题报告
1093 Count PAT's (25 point(s))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 4t...原创 2018-11-02 12:48:38 · 404 阅读 · 0 评论 -
PAT甲级1089,1092解题报告
1089 Insert or Merge (25 point(s))According to Wikipedia:Insertion sort iterates, consuming one input element each repetition, and growing a sorted output list. Each iteration, insertion sort remo...原创 2018-11-01 19:10:54 · 358 阅读 · 0 评论 -
PAT甲级1085,1088解题报告
1085 Perfect Sequence (25 point(s))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 mare the maximum and minim...原创 2018-10-31 14:04:45 · 345 阅读 · 0 评论 -
pat甲级1077,1081题解
1077 Kuchiguse (20 point(s))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...原创 2018-10-30 11:07:10 · 385 阅读 · 0 评论 -
PAT甲级1113,1116解题报告
1113 Integer Set Partition (25 point(s))Given a set of N (>1) positive integers, you are supposed to partition them into two disjoint sets A1 and A2 of n1 and n2 numbers, respectively...原创 2018-10-29 11:38:26 · 232 阅读 · 0 评论 -
PAT甲级1083,1084解题报告
1083 List Grades (25 point(s))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 stud...原创 2018-10-28 20:54:16 · 323 阅读 · 0 评论 -
PAT甲级1074,1075解题报告
1074 Reversing Linked List (25 point(s))Given a constant K and a singly linked list L, you are supposed to reverse the links of every K elements on L. For example, given L being 1→2→3→4→5→6, if K=3,...原创 2018-10-27 12:13:44 · 400 阅读 · 0 评论 -
PAT甲级1071,1073解题报告
1071 Speech Patterns (25 point(s))People often have a preference among synonyms of the same word. For example, some may prefer "the police", while others may prefer "the cops". Analyzing such patter...原创 2018-10-26 13:53:44 · 338 阅读 · 0 评论 -
PAT甲级1069,1070解题报告
1069 The Black Hole of Numbers (20 point(s))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-decreasin...原创 2018-10-25 08:24:29 · 442 阅读 · 0 评论 -
PAT甲级1065,1067题解
1065 A+B and C (64bit) (20 point(s))Given three integers A, B and C in [−263,263], you are supposed to tell whether A+B>C.Input Specification:The first line of the input gives the posit...原创 2018-10-24 23:29:35 · 239 阅读 · 0 评论 -
PAT甲级1062,1063解题报告
1062 Talent and Virtue (25 point(s))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 bei...原创 2018-10-23 14:19:30 · 320 阅读 · 0 评论 -
PAT甲级1060,1061解题报告
1060 Are They Equal (25 point(s))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 chopp...原创 2018-10-22 11:49:34 · 340 阅读 · 0 评论 -
PAT甲级1058,1059
1058 A+B in Hogwarts (20 point(s))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 G...原创 2018-10-21 10:13:53 · 317 阅读 · 0 评论 -
PAT甲级1056,1057解题报告
1056 Mice and Rice (25 point(s))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...原创 2018-10-20 14:40:35 · 368 阅读 · 0 评论 -
探究在linux下和windows下atoi函数在溢出处理的区别
最近在复习数据结构刷leetcode的时候突然出现了一个问题。上面这是题目,当然简单的做肯定简单,我想用atoi和to_string函数,然后就出现问题了。本来我在windos本机测试,当数字正溢出的时候,atoi返回的数字都是INT_MAX,然后就想当然拿aoti函数测试,如果返回的数字是INT_MAX的时候,就表示溢出了直接返回0.然后提交之后,死活就不对,查看了一下执行结果,...原创 2018-10-20 01:54:06 · 1001 阅读 · 1 评论 -
PAT甲级1052,1054解题报告
1052 Linked List Sorting (25 point(s))A linked list consists of a series of structures, which are not necessarily adjacent in memory. We assume that each structure contains an integer key and a N...原创 2018-10-19 13:47:18 · 271 阅读 · 0 评论 -
PAT甲级1050,1051解题报告
1050 String Subtraction (20 point(s))Given two strings S1 and S2, S=S1−S2 is defined to be the remaining string after taking all the characters in S2 from S1. Your task is simpl...原创 2018-10-18 18:04:53 · 417 阅读 · 0 评论 -
PAT甲级1048,1049解题报告
1048 Find Coins (25 point(s))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...原创 2018-10-17 16:53:33 · 436 阅读 · 0 评论 -
树状数组总结
第一次接触树状数组是大一时候还在企图搞算法竞赛的时候,但那个时候也没什么心思花在上面,没搞懂过,只是抄抄模板水水过。现在为了考研明年要考PAT,开始刷PAT题库了而且碰到这种题目了,没办法了,只能学一下了。也不是很深入,但是我觉得用用是够了。下面是介绍。一.树状数组要解决的问题: 有过算法学习经验的人应该都知道POJ一道经典的区间求和题,是的树状数组可以解决,区间的更新,区间的求和还...原创 2018-10-16 18:47:53 · 331 阅读 · 0 评论 -
PAT甲级1044,1047解题报告
1044 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 cha...原创 2018-10-16 14:31:52 · 492 阅读 · 0 评论 -
PAT甲级1041,1042解题报告
1041 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,104]. T...原创 2018-10-15 10:36:10 · 330 阅读 · 0 评论 -
PAT甲级1039,1040解题报告
1039 Course List for Student (25 分)Zhejiang University has 40000 students and provides 2500 courses. Now given the student name lists of all the courses, you are supposed to output the registered co...原创 2018-10-14 14:53:14 · 345 阅读 · 0 评论 -
PAT甲级1037,1038解题报告
1037 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 t...原创 2018-10-13 13:59:10 · 503 阅读 · 0 评论